2014-11-04 83 views

回答

0

沒有使用新的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> 

。 。 。