我正在研究WPF应用程序。
我只想在从组合框中选择项目时显示我的树视图。
这是我的组合框选择属性
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"
At this.NotifyPropertyChanged(()=&gt; IsTransactionNameSelected.ToString());我收到错误(无法将lambda表达式转换为'string'类型,因为它不是委托类型),我的NotifyPropertyChanged采用字符串
答案 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;
}
}