1

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

用户控制

堆栈面板

ListView ItemsSource="{Binding LineItems}" SelectedItem="{Binding SelectedLineItem}"

网格视图

GridViewColumn

GridViewColumn.CellTemplate

数据模板

TextBox Text="{绑定说明}"


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

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

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

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

谢谢!

爸爸猫

4

1 回答 1

2
<TextBox IsEnabled="{Binding DataContext.AllowEdit, RelativeSource={RelativeSource AncestorType=ListView}}"/>
于 2013-09-13T21:53:18.733 回答