Prism 4.2 - WPF popup window customization

Topics: Prism v4 - WPF 4
Apr 3, 2014 at 9:52 AM
I am just wondering whether it is possible to customize more a Popup window (PopupWindowAction) beyond setting the IsModal and CenterOverAssociatedObject properties of it. For example:
  • It would be great if the Minimize and Maximize button of the displayed view can be enabled/disabled
  • The view will always be shown in the the taskbar. A similar property like the ShowInTaskbar would be very useful.
For a relevant example, please open the <Quickstart>\Interactivity.

Thanks.
Apr 4, 2014 at 6:46 PM
Hi,

You would be able to extend the Customizable Window Properties by modifying the Interactivity project from the Prism Library.

Both properties you mentioned may be configured from the corresponding InteractionRequestViewModel raise methods according to each popup view desire Style. In order to accomplish this, you would need to implement the desired Properties into the INotification (and also Notification) class, and generate the Bindings into them from the DefaultNotificationWindow.xaml class. You could also extend more Window properties in the same way than these ones described.

The following code shows how the CustomPopupView would have the Maximize and Minimize buttons disabled. And the DefaultNotification popup would have configured not to be shown in the TaskBar:
InteractionRequestViewModel.cs
...
private void RaiseCustomPopupView()
{
     // In this case we are passing a simple notification as a parameter.
     // The custom popup view we are using for this interaction request does not have a DataContext of its own
     // so it will inherit the DataContext of the window, which will be this same notification.
     this.InteractionResultMessage = "";
     this.CustomPopupViewRequest.Raise(
         new Notification { Content = "Message for the CustomPopupView", Title = "Custom Popup", ResizeMode = ResizeMode.NoResize, TaskBar = true });
}
...
private void RaiseNotification()
{
     // By invoking the Raise method we are raising the Raised event and triggering any InteractionRequestTrigger that
     // is subscribed to it.
     // As parameters we are passing a Notification, which is a default implementation of INotification provided by Prism
     // and a callback that is executed when the interaction finishes.
     this.NotificationRequest.Raise(
        new Notification { Content = "Notification Message", Title = "Notification", ResizeMode = ResizeMode.CanResize, TaskBar = false },
        n => { InteractionResultMessage = "The user was notified."; });
}
public interface INotification
{
    /// <summary>
    /// Gets or sets the title to use for the notification.
    /// </summary>
    string Title { get; set; }

    /// <summary>
    /// Gets or sets the content of the notification.
    /// </summary>
    object Content { get; set; }

    /// <summary>
    /// Gets or sets the resize mode of the notification window.
    /// </summary>
    System.Windows.ResizeMode ResizeMode { get; set; }
        
    /// <summary>
    /// Gets or sets the a boolean for being the Notification Window visible on the task bar.
    /// </summary>
    bool TaskBar { get; set; }
}
I hope this helped,
Regards.

Gabriel Ostrowsky
https://blogs.southworks.net/gostrowsky
Apr 25, 2014 at 9:36 PM
Hi Gabriel,

So this means that I have to modify Prism source code in order to achieve the desired behavior. Is there any other solution/workaround for it?
On the other hand, I have found a blog post about displaying a dialog with Prism and the implementation is very similar to the offical Prism based one, however it has a Window instead of a User Control:
http://blog.magnusmontin.net/2013/04/20/implement-a-confirmation-dialog-in-wpf-with-mvvm-and-prism/
Coordinator
Apr 25, 2014 at 11:27 PM
Hi Gabriel,

Instead of modifying the Prism source code, you can just derive from PopupWindowAction. The GetWindow and PrepareContentForWindow methods are both virtual so you can provide your own implementation if the base implementation is not sufficient.

If that doesn't provide enough flexibility, you can derive from TriggerAction<FrameworkElement> and implement your own Blend action.
Oct 9, 2014 at 9:25 AM
Edited Oct 9, 2014 at 9:25 AM
HI,
I also need the same, i want to disable maximize and minimize button,also i need to remove close button from the notification window.I gone through the code you given here but it didn't help me much as am new to Prism.Can u please explain how o to implement the desired Properties into the INotification (and also Notification) class as am not aware of that. can please give me sample .