14
다음과 같이 명령을 바인딩합니다.MVVM에서 CommandParameter 값 받기
<Button Command="{Binding NextCommand}"
CommandParameter="Hello"
Content="Next" />
여기에서 CommandCarameter 속성을 바인딩하여 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);와 같이 사용할 수 있습니다. –