Reputation: 341
I have an enum
like:
enum Gender
{
Male = 1,
Female = 2
}
Then I have a Combobox
binding to a list of Gender
.
<ComboBox ItemSource = 'Binding GenderList, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged'
SelectItem = 'Binding SelectedGender' />
When user opens the view, how can I make ComboBox
selection default to blank? Then after user made a selection, the blank selection is removed from the ComboBox
source.
Thanks
Thanks all the replies. I fixed my problem by manully assigning the selected item to null.
Upvotes: 1
Views: 5801
Reputation: 20850
What you are describing is the default behavior of the ComboBox. You don't need to do anything (except for correct the typos in your XAML. It should look like:
<ComboBox ItemsSource="{Binding GenderList}" SelectedItem="{Binding Path=SelectedGender}" ></ComboBox>
Upvotes: 2