Problems adding Blend behavior to DatePicker

穿精又带淫゛_ 提交于 2019-12-10 04:22:56

问题


I'm trying to add a Blend behavior to a DatePicker control to bind an MVVM-Light RelayCommand to the DateChanged event like so:

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

I'm using the following definitions:

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

However, I keep getting the following error:

WinRT information: Cannot add instance of type
'Microsoft.Xaml.Interactions.Core.EventTriggerBehavior' to a collection of type 
'Microsoft.Xaml.Interactivity.BehaviorCollection'.

I have successfully used Blend behaviors in this way many other times in my project (and with other controls in the same Xaml file) to bind an event to a command, and the DatePicker control is the only one that has thrown an error. Is there another way to accomplish this or are WinRT DatePickers limited in this way?

来源:https://stackoverflow.com/questions/24309546/problems-adding-blend-behavior-to-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!