Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 绑定文本框已启用到VM的属性_Wpf_Mvvm - Fatal编程技术网

Wpf 绑定文本框已启用到VM的属性

Wpf 绑定文本框已启用到VM的属性,wpf,mvvm,Wpf,Mvvm,这是我视图中经过清理的控件层次结构及其绑定(我希望这样不会删除前导空格!!!) 用户控制 堆垛板 ListView ItemsSource=“{Binding LineItems}”SelectedItem=“{Binding SelectedLineItem}” 网格视图 GridViewColumn GridViewColumn.CellTemplate 数据模板 TextBox Text=“{Binding Description}” LineItems和SelectedLineItem

这是我视图中经过清理的控件层次结构及其绑定(我希望这样不会删除前导空格!!!)

用户控制

堆垛板

ListView ItemsSource=“{Binding LineItems}”SelectedItem=“{Binding SelectedLineItem}”

网格视图

GridViewColumn

GridViewColumn.CellTemplate

数据模板

TextBox Text=“{Binding Description}”


LineItems和SelectedLineItem是我的ViewModel中的属性,而Description是SelectedLineItem引用的类中的属性。

现在,我需要根据ViewModel中的新“AllowEdit”属性启用/禁用文本框(AllowEdit不是SelectedLineItem的属性)

如何将TextBox的IsEnabled属性绑定到AllowEdit属性

我已经做了必要的阅读,但它不清楚如何做到这一点

谢谢

DadCat


<TextBox IsEnabled="{Binding DataContext.AllowEdit, RelativeSource={RelativeSource AncestorType=ListView}}"/>