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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With