簡體   English   中英

將TextBox IsEnabled綁定到VM的屬性

[英]Binding TextBox IsEnabled to property of VM

這是我的View中經過清理的控件層次結構及其綁定(我希望SO不會刪除前導空格!!!)...

用戶控件

StackPanel中

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

網格視圖

GridViewColumn

GridViewColumn.CellTemplate

DataTemplate中

TextBox Text =“ {綁定描述}”


LineItems和SelectedLineItem是我的ViewModel中的屬性, 而Description是SelectedLineItem引用的類中的屬性。

現在,我需要基於ViewModel中的新“ AllowEdit”屬性來啟用/禁用TextBox(AllowEdit不是SelectedLineItem的屬性)。

如何將TextBox的IsEnabled屬性綁定到AllowEdit屬性?

我已經完成了必讀的內容,但尚不清楚如何執行此操作!

謝謝!

DadCat

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM