Why ComboBox SelectionChanged
event fire when we changed value of combobox in WPF?
<telerik:RadComboBox Name="onClockComboBox" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Width="200" Height="30" StaysOpenOnEdit="True" IsSynchronizedWithCurrentItem="True" OpenDropDownOnFocus="True"
ItemsSource="{Binding TravelOtherModel.OnClockOptionListCollection,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center"
DisplayMemberPath="OptionName" SelectedValuePath="RowNo" IsFilteringEnabled="True" IsEditable="True" Margin="80,3,0,0">
<ie:Interaction.Triggers>
<ie:EventTrigger EventName="SelectionChanged">
<ie:InvokeCommandAction Command="{Binding OnClockComboBoxSelectedItemChangedCommand}" CommandParameter="{Binding ElementName=onClockComboBox}" >
</ie:InvokeCommandAction>
</ie:EventTrigger>
</ie:Interaction.Triggers>
</telerik:RadComboBox>
SelectionChanged
event Code is -
public void OnClockComboBoxSelectedItemChangedCommand_Event(object obj)
{
try
{
RadComboBox onClockComboBox = obj as RadComboBox;
var item = onClockComboBox.SelectedItem as OnClockOption;
string s= onClockComboBox.SelectedValue.ToString();
onClockComboBox.SelectedValue = "0";
}
catch (Exception ex)
{
}
}
When we set default selected value by below code then its again firing SelectionChanged
event why?
onClockComboBox.SelectedValue = "0";
When we set default 'select' value by below code then its again firing selection Changed event why?
Because it should, otherwise how will you get notified if the combo box is reset. Assuming your selected value is bound to load some other control. It would require to know if the selection has changed even for the default value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.