InteractionRequests: ToastPopupAction

Topics: Prism v4 - Silverlight 4
Jun 29, 2011 at 3:39 PM


[Windows Phone 7 app]

I am trying to figure out how to use Interaction Requests with a Toast notifications, so far (at best) I have received an InvalidCastException when I execute the _confirmSyncInteraction.Raise event - here is my code:


      // raise the sync completed trigger
                new Notification() { Title = "Sync Complete", Content = "gfsgfdsgfdsgdfd"},
                action => new ToastPopupAction() { PopupElementName = "SyncPopup", IsEnabled = true});

and with a corresponding trigger in the xaml:
        <DataTemplate x:Name="SyncPopup">
            <Grid MinWidth="250" MinHeight="100">
                <TextBlock TextWrapping="Wrap" Grid.Row="0" Text="fdsgfdsgfsdgfd"/>
        <prism:InteractionRequestTrigger SourceObject="{Binding ConfirmSyncInteractionRequest}">
            <prism:ToastPopupAction PopupElementName="SyncPopup" IsEnabled="True"/>

Any help very much appreciate, Mark



Jun 29, 2011 at 5:45 PM

Hi Mark,

It would be helpful if you could provide us with a repro sample that demonstrates this problem, so that we can help you find the cause for it.


Guido Leandro Maliandi

Jun 29, 2011 at 6:11 PM



Have uploaded a test solution here:

Jul 6, 2011 at 5:42 PM

Hi Mark,

We’ve examined your sample and found that the reason of an InvalidCastException being thrown is that the ToastPopUpAction is trying to cast the popup element you’ve defined in your xaml (in your case SyncPopup which is a DataTemplate) to a PopUp control.

To avoid this problem, we’ve changed your DataTemplate into a PopUp element and placed it inside your Grid (that is to say, we didn’t place it inside the application resources). The xaml looks like this:

<Grid x:Name="LayoutRoot" Background="Transparent" d:DataContext="{Binding Items[0]}">
           <RowDefinition Height="Auto"/>
           <RowDefinition Height="*"/>
<!—A PopUp control must be used in order to place the toast notification-->
       <Popup x:Name="SyncPopup">
           <Grid MinWidth="250" MinHeight="100">
               <TextBlock TextWrapping="Wrap" Grid.Row="0" Text="fsdgfsdgfdsgfs"/>


After applying those changes, we tested the sample and found that it correctly displayed the toast notification.

I hope you find this information useful.


Miguel Bronzovic