Skip to content

Instantly share code, notes, and snippets.

@dgwaldo
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgwaldo/bd087520b219f90a6ce6 to your computer and use it in GitHub Desktop.
Save dgwaldo/bd087520b219f90a6ce6 to your computer and use it in GitHub Desktop.
Prism Custom PopupWindowAction
<UserControl x:Class="KNE.Athena.Infrastructure.UserControls.NotificationPopupView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Width="400"
Height="180"
Name="Root">
<!--The DefaultConfirmationWindow used for a PopupWindowAction in Prism doesn't have Text wrapping. This gives us text wrapping.-->
<DockPanel LastChildFill="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Button DockPanel.Dock="Bottom" AutomationProperties.AutomationId="NotificationPopupCloseButton" Margin="10"
HorizontalAlignment="Right" Width="75" Click="Button_Click">OK</Button>
<Grid DockPanel.Dock="Top">
<TextBlock Margin="10,3" TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Center" Text="{Binding Content}" />
</Grid>
</DockPanel>
</UserControl>
<!-- In your view set the WindowContent property to your user control.
Don't forget the xaml namespace xmlns : i=http://schemas.microsoft.com/expression/2010/interactivity"
-->
< i: Interaction.Triggers>
< interactionRequest: InteractionRequestTrigger SourceObject ="{Binding NotificationRequest, Mode =OneWay } ">
< interactionRequest: PopupWindowAction IsModal= "True" CenterOverAssociatedObject= "True" >
< interactionRequest: PopupWindowAction.WindowContent >
< userControls: NotificationPopupView />
</ interactionRequest: PopupWindowAction.WindowContent >
</ interactionRequest: PopupWindowAction >
</ interactionRequest: InteractionRequestTrigger >
</ i: Interaction.Triggers>
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class NotificationPopupView : UserControl, IInteractionRequestAware
{
public NotificationPopupView()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (this.FinishInteraction != null)
this.FinishInteraction();
}
// Both the FinishInteraction and Notification properties will be set by the PopupWindowAction when the Pop-up is shown.
public Action FinishInteraction { get; set; }
public INotification Notification { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment