首页 文章

将TextBox IsEnabled绑定到VM的属性

提问于
浏览
1

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

用户控件

StackPanel中

ListView ItemsSource =“”SelectedItem =“

网格视图

GridViewColumn

GridViewColumn.CellTemplate

DataTemplate中

TextBox Text =“


LineItems和SelectedLineItem是我的ViewModel中的属性, while Description is a property within the class referenced by SelectedLineItem.

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

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

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

谢谢!

DadCat

1 回答

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

相关问题