Setting the selecteditem on the combobox?

Topics: Conventions
Feb 17, 2012 at 2:41 PM
Edited Feb 17, 2012 at 2:42 PM
I have not been able to figure out how to set the value of my combobox... It 
populates correctly and can get the selectedBreed, but when it comes time to 
set what would be the selecteditem... thats where Im not sure how that is accomplished. 
XAML:
<dxe:ComboBoxEdit x:Name="Breeds"
		  Width="101"
		  Height="25"
		  DisplayMember="Name"
		  IsTextEditable="False" />
C#:
private IObservableCollection<Breed> _breeds; 
public IObservableCollection<Breed> Breeds { 
     get { return _breeds; } 
     set { _breeds = value; NotifyOfPropertyChange(() => Breeds); } } 
private Breed _selectedBreed; 
[Required] 
public Breed SelectedBreed { 
     get { return _selectedBreed; } 
     set { 
             if (_selectedBreed == value) return; 
             _selectedBreed = value; 
             NotifyOfPropertyChange(() => SelectedBreed);  
     } 
}
Any help would be appreciated.
Feb 17, 2012 at 2:49 PM
Edited Feb 17, 2012 at 2:50 PM

Is it possible that the DevExpress ComboBoxEdit is not a Selector? In such a case, conventions would not work, so you should create your own. It's a wild guess, since I don't know the control in question.

 

Edit:

I checked it, and indeed it is not a Selector, I am afraid you need to define a custom convention for that control.

Feb 17, 2012 at 3:02 PM

hmmm more fun... How would I do it with the normal WPF combobox then?

Feb 17, 2012 at 3:04 PM
Edited Feb 17, 2012 at 3:04 PM

In case of Selectors, the SelectedItem is automagically TwoWay-bound to the SelectedBreeder property by CM, so no further action is needed.