Mal*_*rus 6 c# xaml mvvm-light windows-runtime winrt-xaml
我正在尝试向DatePicker控件添加Blend行为,以将MVVM-Light RelayCommand绑定到DateChanged事件,如下所示:
<DatePicker Date="{Binding SelectedDate, Mode=TwoWay}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="DateChanged">
<Core:InvokeCommandAction Command="{Binding DateChangedCommand, Mode=OneWay}"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</DatePicker>
Run Code Online (Sandbox Code Playgroud)
我使用以下定义:
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
Run Code Online (Sandbox Code Playgroud)
但是,我不断收到以下错误:
WinRT information: Cannot add instance of type
'Microsoft.Xaml.Interactions.Core.EventTriggerBehavior' to a collection of type
'Microsoft.Xaml.Interactivity.BehaviorCollection'.
Run Code Online (Sandbox Code Playgroud)
我已经在我的项目中(以及在同一个Xaml文件中的其他控件)中以这种方式成功地使用Blend行为将事件绑定到命令,并且DatePicker控件是唯一抛出错误的控件.有没有其他方法来实现这一点或WinRT DatePickers以这种方式受限?
| 归档时间: |
|
| 查看次数: |
803 次 |
| 最近记录: |