次のようにコマンドをバインドしています。
<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値を取得するには?
前もって感謝します。