Click here to Skip to main content
15,307,363 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have Visual Studio 2015. I am trying to learn PRISM/UNITY/MEF. I have downloaded the Interactivity Quickstart solution. After resolving the reference issues, I now have this error showing up.

The local property "Actions" can only be applied to types that are derived from "TriggerBase"

It is showing this error on the
XAML
<prism:InteractionRequestTrigger..../>
part of the XAML tag.

The curious thing is that it will build and run correctly, BUT I do not have any design-time view of the UserControl. The XAML view just states "Invalid Markup" and points to the above error.

Does anyone have any idea of what is going on?
Full XAML code below.

XAML
<UserControl x:Class="InteractivityQuickstart.Views.InteractionRequestView"
             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" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:prism="http://www.codeplex.com/prism"
             xmlns:views="clr-namespace:InteractivityQuickstart.Views"
             xmlns:viewModels="clr-namespace:InteractivityQuickstart.ViewModels"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
    
    <UserControl.DataContext>
        <viewModels:InteractionRequestViewModel />
    </UserControl.DataContext>

    <i:Interaction.Triggers>

        <!-- All the InteractionRequestTriggers here subscribe to the corresponding interaction requests through simple bindings -->
        <!-- In this case all of them raise a PopupWindowAction, but you can use other actions too -->

        <!-- ERROR IS THIS LINE -->
        <prism:InteractionRequestTrigger SourceObject="{Binding ConfirmationRequest, Mode=OneWay}">
            <!-- This PopupWindowAction does not have a custom view defined, therefore it will try to use a DefaultNotificationWindow -->
            <!-- which is a window used by default by Prism to shown INotification implementations -->
            <!-- That window will be show as a modal dialog and centered over this window -->
            <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"/>
        </prism:InteractionRequestTrigger>

        <prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest, Mode=OneWay}">
            <!-- This PopupWindowAction does not have a custom view defined, therefore it will try to use a DefaultConfirmationWindow -->
            <!-- which is a window used by default by Prism to shown IConfirmation implementations -->
            <!-- That window will be show as a modal dialog and centered over this window -->
            <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"/>
        </prism:InteractionRequestTrigger>

        <prism:InteractionRequestTrigger SourceObject="{Binding CustomPopupViewRequest, Mode=OneWay}">
            <!-- This PopupWindowAction has a custom view defined. When this action is executed the view will be shown inside a new window -->
            <!-- Take into account that the view is created only once and will be reused each time the action is executed -->
            <prism:PopupWindowAction>
                <prism:PopupWindowAction.WindowContent>
                    <views:CustomPopupView />
                </prism:PopupWindowAction.WindowContent>
            </prism:PopupWindowAction>
        </prism:InteractionRequestTrigger>

        <prism:InteractionRequestTrigger SourceObject="{Binding ItemSelectionRequest, Mode=OneWay}">
            <!-- This PopupWindowAction has a custom view defined. When this action is executed the view will be shown inside a new window -->
            <!-- Take into account that the view and its view model are created only once and will be reused each time the action is executed -->
            <prism:PopupWindowAction>
                <prism:PopupWindowAction.WindowContent>
                    <views:ItemSelectionView />
                </prism:PopupWindowAction.WindowContent>
            </prism:PopupWindowAction>
        </prism:InteractionRequestTrigger>

    </i:Interaction.Triggers>

    <Grid>
        <StackPanel>
            <TextBlock Margin="5" FontSize="24" Foreground="DarkGreen" TextWrapping="Wrap">Interaction Requests</TextBlock>
            <TextBlock Margin="5" TextWrapping="Wrap">The InteractionRequest and InteractionRequestTriggers classes usually work in pairs like this:</TextBlock>
            <TextBlock Margin="5,0" TextWrapping="Wrap">The <Bold>InteractionRequest</Bold> goes in the view model and is exposed through a property. When the view model needs to interact with the user, it invokes the Raise method to start the interaction.</TextBlock>
            <TextBlock Margin="5" TextWrapping="Wrap">The <Bold>InteractionRequestTrigger</Bold> goes in the view and subscribes to the InteractionRequest through bindings. When the interaction is raised it will executes its corresponding actions.</TextBlock>
            <TextBlock Margin="5" TextWrapping="Wrap">In this Quickstart, we are using <Bold>PopupWindowActions</Bold> to shown popups when an interaction is raised.</TextBlock>
            
            <Button AutomationProperties.AutomationId="NotificationButton" x:Name="temp" Margin="5" Content="Raise Default Notification" Command="{Binding RaiseNotificationCommand}" />
            <Button AutomationProperties.AutomationId="ConfirmationButton" Margin="5" Content="Raise Default Confirmation" Command="{Binding RaiseConfirmationCommand}" />
            <Button AutomationProperties.AutomationId="CustomPopupButton" Margin="5" Content="Raise Custom Popup View Interaction" Command="{Binding RaiseCustomPopupViewCommand}" />
            <Button AutomationProperties.AutomationId="ItemSelectionButton" Margin="5" Content="Raise Item Selection Popup" Command="{Binding RaiseItemSelectionCommand}" />

            <TextBlock Margin="5" TextWrapping="Wrap">
                Each of the following buttons execute a different command in the view model that raise their corresponding interaction request.
                There is an trigger for each of these buttons that execute a PopupWindowAction with the different settings.
            </TextBlock>
        </StackPanel>

        <TextBlock AutomationProperties.AutomationId="ResultTextBlock" Margin="5" FontWeight="Bold" Foreground="DarkRed" VerticalAlignment="Bottom" Text="{Binding InteractionResultMessage}"/>
    </Grid>
</UserControl>
Posted
Comments
Afzaal Ahmad Zeeshan 1-Sep-15 13:15pm
   
Try inheriting your own class object that you are using from TriggerBase class. Then it will work, it is in the error description itself, The local property "Actions" can only be applied to types that are derived from "TriggerBase".
Erevis 1-Sep-15 13:40pm
   
I understand that it needs to inherit from TriggerBase. And it does. This is not my code, this is a Microsoft Example, and looking up InteractionRequestTrigger on MSDN show that it inherits from TriggerBase, thus my confusion as to what is going on.
Afzaal Ahmad Zeeshan 1-Sep-15 13:58pm
   
Then I would suggest that you report that bug to Microsoft itself to re-package by fixing the bug. Perhaps, Visual Studio 2015 will be causing the problem. :-)
thenymf 14-Oct-15 7:42am
   
I have the same issue, using my own classes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900