WPF Data Trigger not working - ComboBox selected index is not getting set to 0
-
29-10-2019 - |
Question
I want to set the SelectedIndex of ComboBox to 0 when the SelectedItem it is bound to is null by using DataTrigger. But it is not working. Where am I going wrong?
The xaml is as follows:
<ComboBox SelectedItem="{Binding MyObject.color_master, Mode=TwoWay}"
ItemsSource="{Binding MyEntities.color_master}"
DislayMemberPath="COLOR_DESCRIPTION" >
<ComboBox.Style>
<Style TargetType="ComboBox">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=MyObject.color_master}" Value="{x:Null}">
<Setter Property="SelectedIndex" Value="0" />
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
Here MyObject.color_master is null, but still the DataTrigger is not working !
My requirement is very simple, when nothing is selected in combobox, I want the first item to be selected.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow