【发布时间】:2010-03-22 15:19:10
【问题描述】:
以下代码有效,但我很好奇为什么我需要以“DataContext”为前缀的路径?在大多数其他情况下,使用的路径是相对于 DataContext。是因为我使用的是RelativeSource吗?因为源码在根级(Window)?
<Style TargetType="TextBox">
<Setter
Property="IsReadOnly"
Value="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}}, Path=DataContext.IsReadOnly}"/>
</Style>
【问题讨论】:
标签: wpf data-binding