We want to display a message box with the help of PRISM in Silverlight.
There is a different class for displaying an question - Confirmation. We
can display our own window with InteractionRequest<OurViewModel> and some code in XAML
defining which view to run.
Message box class in defined in PRISM's namespace:
namespace: Microsoft.Practices.Prism.Interactivity.InteractionRequest
Class name is Notification.
SomeView, XAML:
<UserControl x:Class="WebClient.SomeView"
..... >
<Grid x:Name="LayoutRoot" Background="White">
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding SaveNotification}">
<prism:PopupChildWindowAction/>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
</Grid>
</UserControl>
SomeViewModel, cs:
public class SomeViewModel
{
public SomeViewModel(......)
{
saveNotification = new InteractionRequest<Notification>();
}
private readonly InteractionRequest<Notification> saveNotification;
//this function displays message box
private void someFunction(object obj)
{
//show message box
((InteractionRequest<Notification>)saveNotification).Raise(new Notification { Title = "Information", Content = "User was saved." });
}
public IInteractionRequest SaveNotification
{
get { return this.saveNotification; }
}
}
No comments:
Post a Comment
If you like this post, please leave a comment :)