2

Silverlight ToolkitのNumericUpDownコントロールがMVVMプロパティとRelayCommandトリガセット(任意のイベント)にバインドされている場合、NumericUpDownがMVVMプロパティ値を変更する前にコマンドが呼び出されます。これは...あなたはあなたの方法/アクション/コマンドを使用して新しい(変更)の値を使用することはできません、意味Silverlight NumericUpDownが値を変更する前のMVVMリレーコマンドトリガー

XAML:この中

DoSomethingCommand = new RelayCommand(() => 
      { 
       OtherRegisterForm = RegisterForm; 
      }); 

<inputToolkit:NumericUpDown x:Name="testNum" Value="{Binding RegisterForm, Mode=TwoWay}"> 
<i:Interaction.Triggers> 
    <i:EventTrigger EventName="ValueChanged"> 
    <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding DoSomethingCommand}"/> 
    </i:EventTrigger> 
</i:Interaction.Triggers> 
</inputToolkit:NumericUpDown> 

MVVM(C#の)場合、v値0を持ち、NumericUpDownコントロールに新しい値123を入力すると、MVVMプロパティの "RaisePropertyChange"イベントの前に "DoSomethingCommand"がトリガーされます。 "OtherRegisterForm"は123でなく0になります。

この方法を使用する方法はありますか?

答えて

1

少年ああ、簡単ではありませんでしたが、ここでuは、次のとおりです。

XAMLの一部:

<toolkit:NumericUpDown Value="{Binding SomeNumber}"> 
     <i:Interaction.Triggers> 
      <i:EventTrigger EventName="ValueChanged"> 
       <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding MyCommand}" PassEventArgsToCommand="True" /> 
      </i:EventTrigger> 
     </i:Interaction.Triggers> 
    </toolkit:NumericUpDown> 

とCSコード:Arek

を助け

public class MainViewModel : ViewModelBase 
{ 

    public double SomeNumber { get; set; } 

    public MainViewModel() 
    { 
     SomeNumber = 10; 
     MyCommand = new RelayCommand<RoutedPropertyChangedEventArgs<double>>(myActionMethod); 
    } 

    public RelayCommand<RoutedPropertyChangedEventArgs<double>> MyCommand { get; set; } 

    public void myActionMethod(RoutedPropertyChangedEventArgs<double> arg) 
    { 
     MessageBox.Show(arg.NewValue.ToString()); 
    } 
} 

希望

関連する問題