WPF 传递 commandparameter 到类

来源:互联网 发布:js对象中定义函数 编辑:程序博客网 时间:2024/04/29 18:23

<Button Command="{Binding NextCommand}"  
   
CommandParameter="Hello"  
   
Content="Next" /> 
----------------------------------------------------------------------------

 

public ICommand NextCommand 
   
{ 
       
get 
       
{ 
           
if (_nextCommand == null) 
           
{ 
                _nextCommand
= new RelayCommand( 
                    param
=> this.DisplayNextPageRecords(param) 
                   
//param => true 
                   
); 
           
} 
           
return _nextCommand; 
       
} 
   
} 

public ObservableCollection<PhonesViewModel> DisplayNextPageRecords(object o) 
   
{ 


            //现在 o 就包含了 "Hello"
            
PageNumber++; 
           
CreatePhones(); 
           
return this.AllPhones; 
 
   
} 

原创粉丝点击