2016-03-07 79 views
3

我使用Interaction.Behaviors在XAML將事件綁定到我的控制,像這樣的實驗,Interaction.Behaviors在Windows 10 UAP

<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> 

這工作完全不同的...的Visual Studio 2015年顯示以下錯誤,

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 

這已經導致設計者破壞,所以即使代碼正常工作,設計師也沒有。有任何想法嗎?

我是包括...

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

而只是爲了澄清,我包括行爲通過「添加引用...」對話框SDK。

+0

我在VS同樣的行爲2015年企業 – Domysee

+1

注意到你標籤是windows-10-universal,而VS是2012年,您是在開發一款UWP應用程序嗎?開發UWP應用程序時,您必須具有vs2015和Windows 10操作系統。而行爲SDK(XAML)12.0版是針對Windows 8.1的,因爲UWP是[XamlBehaviors](https://github.com/Microsoft/XamlBehaviors)。 –

+0

對不起,這是一個錯字2015. – Nick

回答

1

對我有效的答案是Grace Feng在問題中提出的意見,並由Nick證實。

,這樣做的Windows 10的通用應用程序時使用Microsoft.Xaml.Behaviors.Uwp.Managed NuGet包和刪除行爲SDK(XAML)封裝