In two combobox A and B. A\'s ItemsSource is Custom list. and B\'s ItemsSource is UserControl list. When manually setting the SelectedItem, A combobox works well, but B comb
This is not the good way of achieving this. Better define the ItemTemplate for the combobox to have the UserControl in it like:
and define the class Item
public class Item
{
public string ItemName { get; set; }
}
ObservableCollection- _ItemsList = new ObservableCollection
- ();
public ObservableCollection
- ItemsList
{
get
{
return _ItemsList ;
}
set
{
_ItemsList = value;
OnPropertyChanged();
}
}
Here DataContext of your UserControl will be Item
object. you can bind the ItemName within you user control to show it in anyway you want.
in your user control you can have: