0

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?

user436862
  • 867
  • 2
  • 15
  • 32
  • How do I set the SelectedItem DataTemplate? – user436862 Jan 07 '14 at 23:28
  • possible duplicate, check [this question](http://stackoverflow.com/questions/4672867/can-i-use-a-different-template-for-the-selected-item-in-a-wpf-combobox-than-for) it has solution already – har07 Jan 08 '14 at 01:26

0 Answers0