Getting "Unable to add an instance of type EventTriggerBehavior to the BehaviorCollection" to make an interactive TextBlock

There were many buttons in my application that were hardcoded as navigation menus, but I wanted to update this to something more than data driven.

    <Button Content="MyPage">
        <i:Interaction.Behaviors>
            <core:EventTriggerBehavior EventName="Click">
                <core:NavigateToPageAction TargetPage="Namespace.MyPage"/>
            </core:EventTriggerBehavior>
        </i:Interaction.Behaviors>
    </Button>

But when I tried to put this behavior on another XAML element (in particular, TextBlock as part of the data template), I got the following error.

An exception like "Windows.UI.Xaml.Markup.XamlParseException" occurred in NavMockUp.Windows.exe, but was not processed in the user code

WinRT Info: Cannot add an instance of type "Microsoft.Xaml.Interactions.Core.EventTriggerBehavior" to a collection of type "Microsoft.Xaml.Interactivity.BehaviorCollection"

    <TextBlock Text="Click for Page">
        <i:Interaction.Behaviors>
            <core:EventTriggerBehavior EventName="Click">
                <core:NavigateToPageAction TargetPage="Namespace.MyPage"/>
            </core:EventTriggerBehavior>
        </i:Interaction.Behaviors>
    </TextBlock>
+4
1

, , EventTriggerBehaviors

, , TextBlock "Click" .

, Click Tapped, TextBlock .

    <TextBlock Text="Click for Page">
        <i:Interaction.Behaviors>
            <core:EventTriggerBehavior EventName="Tapped">
                <core:NavigateToPageAction TargetPage="Namespace.MyPage"/>
            </core:EventTriggerBehavior>
        </i:Interaction.Behaviors>
    </TextBlock>
+6

All Articles