MVVM Light Hub Control SectionsInViewChanged RelayCommand

时间:2014-11-04 09:37:50

标签: events mvvm-light win-universal-app

是否可以将MVVM Light,Relay命令绑定到集线器控件中的 SectionsInViewChanged 事件?

1 个答案:

答案 0 :(得分:0)

Haven没有使用新的Hub控件,但它应该像其他人一样。您可以使用EventToCommand将RelayCommands绑定到事件。阅读http://msdn.microsoft.com/en-us/magazine/dn237302.aspx

显示此用户控件的Loaded事件绑定触发LoadedCommand的片段:

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

。 。