2013-06-19 40 views
-1

我正在使用WPF應用程序。WPF:無法將lambda表達式轉換爲鍵入'string',因爲它不是委託類型

我想顯示我的treeview只有當我從組合框中選擇項目。

這裏是我的下拉框中選擇屬性選擇或不

public string SelectedTransactionName 
    { 
     set 
     { 
      if (_selectedTransactionWsName == value) return; 
      this._selectedTransactionWsName = value; 

      // InitializaMessageElement(value.WsMethodName, transactionTypes); 
      InitializaMessageElement(); 

      this.NotifyPropertyChanged(()=>IsTransactionNameSelected.ToString()); 
     } 
     get 
     { 
      return this._selectedTransactionWsName; 
     } 

    } 

檢查變速箱的名字。

public bool IsTransactionNameSelected 
    { 
     get 
     { 
      return !string.IsNullOrEmpty(_selectedTransactionWsName); 
     } 
    } 

XAML

<TreeView Margin="464,137,10,413" Grid.RowSpan="2" ItemsSource="{Binding MessageElements, Mode=TwoWay}" 
        SelectedItemChanged="TreeView_OnSelectedItemChanged" Visibility=" {Binding IsTransactionNameSelected,Converter={StaticResource BooleanToVisibilityConverter}}" 
       SelectedValuePath="Id" 

在this.NotifyPropertyChanged(()=> IsTransactionNameSelected.ToString());我得到的錯誤(無法轉換lambda表達式鍵入'字符串',因爲它不是一個委託類型),我的NotifyPropertyChanged採取字符串

+0

您的具體問題是什麼?如果是關於標題,你能否指出人們談論你在說什麼?你還沒有提供完整的代碼,所以人們不得不猜測什麼可以幫助你。代碼中的問題意味着他們不會被注意到。 –

+0

我更新了我的問題 –

回答

2

NotifyPropertyChanged期待一個字符串,並且你傳遞給它一個委託。請嘗試:

public string SelectedTransactionName 
{ 
    set 
    { 
     if (_selectedTransactionWsName == value) return; 
     this._selectedTransactionWsName = value; 

     // InitializaMessageElement(value.WsMethodName, transactionTypes); 
     InitializaMessageElement(); 

     this.NotifyPropertyChanged("SelectedTransactionName"); 
     this.NotifyPropertyChanged("IsTransactionNameSelected"); 
    } 

    get 
    { 
     return this._selectedTransactionWsName; 
    } 
} 
+0

謝謝里德您的解決方案按預期工作! –

相關問題