14
私は次のようなコマンドをバインドしています。MVVMでCommandParameter値を受け取る
<Button Command="{Binding NextCommand}"
CommandParameter="Hello"
Content="Next" />
ここで、CommandParameterプロパティをバインドして、NextCommandからその値をフェッチする方法を示します。
public ICommand NextCommand
{
get
{
if (_nextCommand == null)
{
_nextCommand = new RelayCommand(
param => this.DisplayNextPageRecords()
//param => true
);
}
return _nextCommand;
}
}
その関数の定義:
public ObservableCollection<PhonesViewModel> DisplayNextPageRecords()
{
//How to fetch CommandParameter value which is set by
//value "Hello" at xaml. I want here "Hello"
PageNumber++;
CreatePhones();
return this.AllPhones;
}
CommandParameterの値を取得する方法は?
ありがとうございます。
ありがとう非常に、その作業は非常にありがとうございます。 もう一度ありがとうございます。 –
とし、 '_nextCommand = new RelayCommand(this.DisplayNextPageRecords);のように使うことができます。 –