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'。 –