popupregionbehavior and PopupChildWindowAction

Topics: Prism v4 - Silverlight 4
Nov 15, 2010 at 9:30 AM

I am trying to see which way to take when showing a modal window in silverlight. I want to send additional param to initialize the view. and would like to handle the callback to take appropriate action depending on the return value( whether ok or cancel was pressed)

If I use popupregionbehavior, I could use URIQuery and navigate to the view. but how to get the return value. I could style contentcontrol to have buttons, Is changing code the only option in this case

If I use PopupChildWindowAction, dont see a way to pass initialization params.

Any help is appreciated

Nov 15, 2010 at 7:26 PM

Hi,

If you use Prism Navigation, you could pass parameters as part of the query, and then you could bind your buttons to commands that reside in your ViewModel. And if you need to notify a particular component in a different module, you could use Event Aggregation. For more information on this topic, you could take a look at: Event Aggregation QuickStart

On the other hand, in Prism 4 Interaction Requests are supported, so it allows you to use a PopupChildWindowAction. When call the Raise method of an IIteractionRequest passing a Confirmation argument as shown below , it will display ConfirmationChildWindow, which contains OK and Cancel buttons to capture the user's response. For more information on this topic you could check at the following documentation section on MSDN: Chapter 6: Advanced MVVM Scenarios, see the note at the Using Behaviors to Implement the Interaction User Experience section.

public IInteractionRequest ConfirmCancelInteractionRequest
{
get
{
return this.confirmCancelInteractionRequest;
}
}

----------------------------------------------------------

this.confirmCancelInteractionRequest.Raise(
new Confirmation("Are you sure you wish to cancel?"),
confirmation =>
{
if (confirmation.Confirmed)
{
...
}
});
}
----------------------------------------------------------
<i:Interaction.Triggers>
<
prism:InteractionRequestTrigger
SourceObject="{Binding ConfirmCancelInteractionRequest}">

<
prism:PopupChildWindowAction
ContentTemplate="{StaticResource ConfirmWindowTemplate}"/>

</
prism:InteractionRequestTrigger>
</
i:Interaction.Triggers>

<
UserControl.Resources>
<
DataTemplate x:Key="ConfirmWindowTemplate">
<
Grid MinWidth="250" MinHeight="100">
<
TextBlock TextWrapping="Wrap" Grid.Row="0" Text="{Binding}"/>
</
Grid>
</
DataTemplate>
</
UserControl.Resources>
----------------------------------------------------------

If you need guidance on this topic, you could take a look at the following Quickstart: State-Based Navigation QuickStart

Hope this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero

Nov 15, 2010 at 9:49 PM

ok, Thanks

Dec 15, 2010 at 3:46 PM

Ok, I've tried to implement the interaction, as a way of handling delete confirmation.

When the user hits delete, it triggers my deletecommand, which does a raide on my confirmation Interaction request. The child window comes up, and the confirm box displays. When the user clicks ok or cancel, the dialog (child window) goes away. However, the underlying control stays greyed out.

Is there some way I need to signal that the page should go back to dialog mode?

View

<UserControl
...
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding DeleteConfirmationInteractionRequest, Mode=OneWay}">
<prism:PopupChildWindowAction ContentTemplate="{StaticResource ConfirmWindowTemplate}"/>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>

ViewModel
private readonly InteractionRequest<Confirmation> deleteConfirmationInteractionRequest;
...
this.deleteConfirmationInteractionRequest = new InteractionRequest<Confirmation>();
...
public void PermissionDeleteExecute(XamDataTree tree)
{
if (tree.ActiveNode != null)
{
this.deleteConfirmationInteractionRequest.Raise(new Confirmation() { Content = "Are you sure you wish to delete?" },
confirmation =>
{
if (confirmation.Confirmed)
{
//handle delete
 }
});
}

}
Any ideas?

 

Dec 16, 2010 at 7:56 PM

Hi,

We´ve had no similar issues reported so far related with Interaction Request Objects.

Based on my understanding of your scenario, it seems to be a communication problem between the popup and the underlying visual components. At first sight your view and your view model's code that you showed us don't seem to have anything that could cause the behavior you're mentioning. It could be helpful if you could provide us with a repro sample, so that we can help you identify and solve your issue.

Also you can explore MVVM Reference Implementation Solution where you can find an example of a similar scenario implemented, here.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic