2014-10-17 34 views

回答

0
//This is command defining 
private ICommand myCommand; 

public ICommand MyCommand 
{ 
    get 
    { 
     if (myCommand== null) 
     myCommand= new RelayCommand(MyMethod); 
     return myCommand; 
    } 
    set { myCommand= value; } 
} 


    //This is your command method 
    public void MyMethod() 
    { 
    } 

    //This is your xaml 
    <Button Command="{Binding MyCommand}"/> 

如果需要參數傳遞給方法;

myCommand= new RelayCommand<object>(MyMethod);//Change here like this; 

並改變這樣

//You can pass string parameter 
<Button Command="{Binding MyCommand}" CommandParameter="MyParameter"/>   
Or 
//You can pass a property 
<Button Command="{Binding MyCommand}" CommandParameter="{Binding MyProperty}"/> 
的XAML
1

可以爲here創建自己的命令,然後指定爲

tbi.DoubleClickCommand = YourCreatedCommand; 

您也可以參考:here瞭解更多信息