I have some ComboBox
controls, each with some values. Each selected value triggers one of my events.
When item selected from ComboBoxA, my event is triggerd with the value of the selected item.
When one of my combo boxes is just opened and closed, no value changed in it, the event is not triggerd (this is the default behaviour of a combobox).
But this is not what i need.
What i did, is to create a behavior that will associate with the DropDownClosed
event, but i don't know how to trigger the SelectionChanged
event.
Edit:
This question can be generalized: How to 'manually' trigger an event of a UI control? or - Is there a way to invoke the methods assosiated with an event?
Edit 2:
I'll try to explain the problem more clearly. I have this code, which takes a list of items, and present them as categories (Radio button) and items under category (ComboBox inside RadioButton). When selecting an item - the selection changed event is triggerd. OK! when selecting another radio button - an event is triggered. OK!!
Special case that not work (as default for ComboBox behavior): when opening one of the combo that is not selected and than closing it without changing its selection - no event is triggered. BUT - this combo is under a not selected category that i want to be selected now, sincr the user thouched it. My idea was to use behavior (is in xaml code, but so far is not working...)
The code (more or less...):
<ListBox ItemsSource="{Binding Categories}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<RadioButton Content="{Binding CategotyName}" GroupName="TestCategory" IsChecked="{Binding IsSelected}"
cal:Message.Attach="SelectionChanged($dataContext)]"/>
<ComboBox cal:Message.Attach="SelectionChanged($dataContext)]"
ItemsSource="{Binding TestsNamesUnderCategory}" SelectedIndex="{Binding SelectedTestInx, Mode=TwoWay}">
<i:Interaction.Behaviors>
<local:ComboBoxReSelectionBehavior />
</i:Interaction.Behaviors>
</ComboBox>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
the line cal:Message.Attach="SelectionChanged($dataContext)]"
is using Caliburn framework, it just send the trigger to my method.
Hope this is more clear now. Thanks!