2010-05-27 43 views
0

我是WPF和tring學習WPF複合應用程序的新手。
我有用戶控件,它是一個模塊,其上有1個標籤和1個按鈕。
現在我試圖使用Command屬性上的按鈕,看起來像Wpf usercontrol的按鈕沒有觸發演講者的ICommand

<Button Name="button1" Command="{Binding Path = GetCustomerNameCommand}">GetCustomer</Button> 

在我有

public class HelloWorldPresenter : PresenterBase<IHelloWorldView> 
    { 
     private readonly IWpfService _wpfService; 

     public HelloWorldViewModel CustomerViewModel { get; set; } 

     public ICommand GetCustomerNameCommand { get; set; } 

     public HelloWorldPresenter(IHelloWorldView view, IWpfService wpfService) 
      : base(view) 
     { 
      _wpfService = wpfService; 

      GetCustomerNameCommand = new DelegateCommand<string>(GetCustomerName); 
      View.Presenter = this; 

      PopulateViewModel(string.Empty); 
     } 

     private void GetCustomerName(string obj) 
     { 
      throw new NotImplementedException(); 
     } 

     private void PopulateViewModel(string test) 
     { 
      CustomerViewModel = new HelloWorldViewModel { Name = _wpfService.GetCustomer() }; 
     } 
    } 

的是沒有得到執行的事情GetCustomerName()方法時,我點擊演示按鈕

+0

有沒有什麼錯的c你已經向我們展示了頌歌,所以這個問題必須在你沒有顯示的代碼中。 'DelegateCommand'的'CanExecute()'返回什麼?它會返回「false」嗎? – bitbonk 2010-05-27 11:32:15

+0

我沒有CanExecute命令。 你想讓我添加其他代碼嗎? – Miral 2010-05-27 14:03:50

回答

0

我發現它,我添加相同的看法2次,這是造成問題...