公共交互会触发WPF MVVM

时间:2015-03-25 06:10:24

标签: wpf xaml mvvm telerik

我在使用WPF模型的MVVM应用程序中工作。我正在使用交互式触发器验证组合框。现在我有一些RadCombobox,我必须编写一个公共交互tirgger并传递CommandParameter中的一些常用值,以便我可以同时验证所有值。

现在我已经为一个组合框写了,它工作正常。只是想知道是否有可能。

// XAML代码:

<telerik:RadComboBox Grid.Row="1" Grid.Column="1" Height="23" IsEditable="True" Name="cmbSeriesColor" ItemsSource="{Binding ColorList, Mode=TwoWay}" SelectedValuePath="Id" DisplayMemberPath="Descr" SelectAllTextEvent="GotFocus" 
SelectedValue="{Binding SelectedMarketSeries.ColorId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}"
telerik:StyleManager.Theme="Windows8" Margin="2 0 2 0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding ColorLostFocus, Source={StaticResource ColorViewModel}}" CommandParameter="{Binding ElementName= cmbSeriesColor, Path=SelectedItem }" />
</i:EventTrigger>
</i:Interaction.Triggers>
</telerik:RadComboBox>

我可以将上面写的交互触发器作为4个组合框的通用吗?

//查看型号代码:

  public ICommand ColorLostFocus { get { return new RelayCommand(new Action<object>(ValidateColor)); } }

        private void ValidateColor(object obj)
        {
           // throw new NotImplementedException();
        }

还有其他办法吗?

0 个答案:

没有答案