I create a UserControl:
public partial class TestUserControl : UserControl
{
....
private string _name;
public string MyName
{
get { return _name; }
set { _name = value; }
}
...
}
And a collection of the TestUserControl with different names.
My Combobox:
<ComboBox Height="50" Width="100" ItemsSource="{Binding MyCollection}" SelectedItem="{Binding SelectUC}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Label Background="Green" Content="{Binding MyName}"></Label>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
the dropdown list is shown as Label with green background and the text value of "MyName" property but the selected item been shown as the TestUserControl and not by the DataTemplate.
How can i set the Datatemplate to represent the selected item the same way like the items in the dropdown list?