Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interaction.Behaviors in Windows 10 UAP

I'm experimenting with using Interaction.Behaviors in XAML to bind events to my controller like so,

<GridView x:Name="mygrid" >
    <interact:Interaction.Behaviors>
        <interactcore:EventTriggerBehavior EventName="SelectionChanged">
            <interactcore:InvokeCommandAction
                Command="{Binding Controller.Test}"
                CommandParameter="{Binding ElementName=mygrid, Path=SelectedItem}"/>
        </interactcore:EventTriggerBehavior>
    </interact:Interaction.Behaviors>
</GridView>

This works perfectly except... Visual Studio 2015 shows the following errors,

Severity    Code    Description Project File    Line    Suppression State
Error       The name "EventTriggerBehavior" does not exist in the namespace "using:Microsoft.Xaml.Interactions.Core".   MVC C:\Prototype\MVC\MVC\MainPage.xaml  19  
Error       The name "InvokeCommandAction" does not exist in the namespace "using:Microsoft.Xaml.Interactions.Core".    MVC C:\Prototype\MVC\MVC\MainPage.xaml  20  
Error       The name "Interaction" does not exist in the namespace "using:Microsoft.Xaml.Interactivity".    MVC C:\Prototype\MVC\MVC\MainPage.xaml  18  

This has caused the designer to break, so even though the code works, the designer doesn't. Any ideas?

My includes are...

xmlns:interact="using:Microsoft.Xaml.Interactivity"
xmlns:interactcore="using:Microsoft.Xaml.Interactions.Core"

And just to clarify, I included the behaviors SDK via the "Add Reference..." dialog.

like image 496
Nick Avatar asked Mar 07 '16 16:03

Nick


People also ask

Are XAML behaviors supported for UWP?

Today we announce the next step: XAML Behaviors natively supported for UWP and shipping as a NuGet package (for both native and managed projects). Additionally, to build a vibrant community around the platform, Behaviors are open source and on GitHub. Now, you can help influence the future direction of Behaviors.

What is behaviors in DevOps?

Behaviors should be a toolkit that target a wide audience of developers and empowers them to be more productive. The Behaviors taken into the project should address common and core user scenarios that many will find value in.

What is now behaviors in WPF?

Now, you can help influence the future direction of Behaviors. Originally released for WPF and Silverlight, and based on the concept of EventTriggers in WPF, designers and developers used Behaviors as an easy means for rapidly building their apps while promoting code reuse.

How do I get the latest version of behaviors?

Now, the Assets Pane prompts users with a link to install the NuGet Package. Clicking this link will download and reference the latest NuGet Package and will populate the list with all the latest and greatest Behaviors. You will also be able to get the latest version of Behaviors in both Visual Studio and Blend using the NuGet Package Manager.


1 Answers

The answer that worked for me were the comments made by Grace Feng in the question and confirmed by Nick.

That is when doing Windows 10 Universal apps use the Microsoft.Xaml.Behaviors.Uwp.Managed nuget package and remove the Behaviors SDK (XAML) package

like image 143
schnitty Avatar answered Nov 15 '22 05:11

schnitty