0
我有2个特性的视图模型:绑定到CollectionViewSource在XAML
- IsReadOnly
- SomeCollectionViewSource
这是一个简单的工作视图例如:
<StackPanel DataContext="{Binding SomeCollectionViewSource}">
<DatePicker SelectedDate="{Binding Path=Date}" IsEnabled="False" />
</StackPanel>
现在我想要绑定IsEnabled属性:
<StackPanel DataContext="{Binding}">
<DatePicker SelectedDate="{Binding Path=?}" IsEnabled="{Binding IsReadOnly}" />
</StackPanel>
该示例中的绑定应该如何? (我想我正在做一件简单的事情)
由于我有很多控件需要绑定,所以我宁愿选择简单又容易的绑定。
是否有更好/更简单的方法使一个CollectionViewSource的所有控件只读?
感谢,我学到了很多来源于此。空的DataContect绑定只是为了显示不同之处。现在我只是缺少DatePicker上的IsReadOnly属性。 – r03
我不得不使用{Binding SomeCollectionViewSource.View/Date} – r03
@Roeland:哦,对,绑定是直接的源,因为它的目标是属性路径,如果CollectionViewSource被设置为'Binding.Source'(或DataContext),绑定将隐含地定位到'View',所以在这些情况下,路径只会是'/ Data'。 –