I\'ve got a ComboBox that contains paths to Images and I need to use the selected path as a source for an Image object. I\'ve tried to bind it like this:
...
<
Since you are explicitly creating ComboBoxItems, you have to use their Content property to access the item object:
Source="{Binding ElementName=ComboBox, Path=SelectedItem.Content}"
Note that setting UpdateSourceTrigger=PropertyChanged
has no effect in this Binding.
Alternatively, you may set the ComboBox's SelectedValuePath
property to "Content"
and bind to SelectedValue
instead of SelectedItem
:
...
Images/men.png
Images/women.png
Another alternative would be to use String items instead of ComboBoxItems:
xmlns:system="clr-namespace:System;assembly=mscorlib"
...
...
Images/men.png
Images/women.png