I’m trying to set one of two Bindings on a ListBox‘s ItemsSource (based on the selection in a group of RadioButtons).
What I have now is:
<ListBox>
<ListBox.Resources>
<Binding x:Key="AllBinding" Path="ItemsSource.AllLeaves" ElementName="EmployeeTree" />
<Binding x:Key="FolderBinding" Path="SelectedItem.Leaves" ElementName="EmployeeTree" />
</ListBox.Resources>
</ListBox>
Then ideally I would set one or the other to the ItemsSource based on the user’s selection.
But I get this error on both Bindings:
A ‘Binding’ cannot be set on the ‘Value’ property of type ‘DictionaryEntry’. A ‘Binding’ can only be set on a DependencyProperty of a DependencyObject.
How can I implement this requirement? Is it even possible to define the Bindings so I can just swap them in and out from code behind?
It sounds like you are trying to set your
TreeView.ItemsSourcebased on the selected item in someListBox.If this is the case, you should write a
DataTriggeron yourEmployeeTreethat setsTreeView.ItemsSourcebased on theListBox.SelectedItemorListBox.SelectedIndexUpdate based on comments below