【发布时间】:2012-07-09 13:45:42
【问题描述】:
我正在尝试在ListBox 的ItemsSource 上设置两个Bindings 之一(基于一组RadioButtons 中的选择)。
我现在拥有的是:
<ListBox>
<ListBox.Resources>
<Binding x:Key="AllBinding" Path="ItemsSource.AllLeaves" ElementName="EmployeeTree" />
<Binding x:Key="FolderBinding" Path="SelectedItem.Leaves" ElementName="EmployeeTree" />
</ListBox.Resources>
</ListBox>
理想情况下,我会根据用户的选择将其中一个设置为ItemsSource。
但我在Bindings 上都收到此错误:
不能在“DictionaryEntry”类型的“Value”属性上设置“Binding”。 “绑定”只能在 DependencyObject 的 DependencyProperty 上设置。
如何实现此要求?是否可以定义Bindings,以便我可以将它们从后面的代码中交换出来?
【问题讨论】:
标签: c# .net wpf xaml data-binding