I have a ComboBox
with 2 items. But on the loaded page I print an item not from the datasource which also has index 0.
How can I detect the click event on the first item (index 0) from the dropdownlist.
I need to distinguish the object A index 0 which is the displayed Item and the object B index 0 from the dropdownlist. The Object A is displayed using text property of the combobox, so its assigned inndex is 0.
I can't use SelectionChanged
because the event is based on SelectedIndex
. here both have the same.
Here is some code, but not so helpfull (I tried using PreviewMouseLeftButtonUp
, but the event is not triggered on item) :
XAML
<telerik:RadComboBox x:Name="Combo" ItemsSource="{Binding ListeIndexationInit, Mode=OneWay}" SelectedValue="{Binding SelectedCodeIndexInitVentePV, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PreviewMouseLeftButtonUp="Combo_PreviewMouseLeftButtonUp">
My code Behind xaml.cs
//Does not get the right index
private void RadComboBox_LostFocus(object sender, RoutedEventArgs e)
{
RefOffreIndex value = Combo.SelectedValue as RefOffreIndex;
if (value != null)
{
Combo.Text = value.ToString();
}
Combo.SelectedIndex = -1;
var SelectionBoxItem = Combo.SelectionBoxItem;
Combo.SelectedItem = value;
var bindingExpression = Combo.GetBindingExpression(RadComboBox.SelectedItemProperty);
}
//Never triggered
private void Combo_SourceUpdated(object sender, DataTransferEventArgs e)
{
Combo.SelectedIndex = -1;
}
//Event is too early
private void Combo_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var toto = 2;
}