【发布时间】:2014-11-04 09:37:49
【问题描述】:
是否可以将 MVVM Light、Relay 命令绑定到集线器控件中的 SectionsInViewChanged 事件?
【问题讨论】:
标签: events mvvm-light win-universal-app
是否可以将 MVVM Light、Relay 命令绑定到集线器控件中的 SectionsInViewChanged 事件?
【问题讨论】:
标签: events mvvm-light win-universal-app
没用过新的Hub控件,不过应该和其他的一样吧。您可以使用 EventToCommand 将 RelayCommands 绑定到事件。阅读http://msdn.microsoft.com/en-us/magazine/dn237302.aspx。
显示此用户控件绑定触发 LoadedCommand 的 Loaded 事件的片段:
<UserControl x:Class="Bill.Views.Setup.AdjustmentReasonsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
xmlns:igDP="http://infragistics.com/DataPresenter"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<cmd:EventToCommand Command="{Binding Mode=OneWay, Path=LoadedCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
。 . .
【讨论】: