Hello Infragistics team.
I have a need to harness the event for 'SelectionChanged' from a combobox that is embedded in a xamDataGrid.
I need this event to fire whenever a user changes the selection, and to be able to determine the record where the change occurred.
My XAML for the combobox is very simple. In the grid resources I've got:
<
igEditor:ComboBoxItemsProvider x:Key="GridProcessorColumn" />
And the code-behind sets it up (in the FieldLayoutInitialized method) with something like this:
processor.Settings.EditorStyle = xamDGOpenInfr.TryFindResource(
"ProcessorColumnStyle") as Style;
Can someone tell me please how to accompish this? I'm still new to WPF/Infragistics and I have no idea how to set up the code to give me the event that I'm after.
Thanks!
I can add this to my style:
XAML
<EventSetter Event="SelectedItemChanged" Handler="Processor_SelectedItemChanged" />
Code-behind
void
Processor_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
Which does work, but I don't see how to get the row/record.
Any help for that?
Hello,
You have to traverse the element tree and find the presenter, that this XamCOmboEditor is placed in.
You can do that using our helper methods : Infragistics.Windows.Utilities.GetAncestorFromType(...) and look for the CellValuePresenter or DataRecordPresenter, which expose the record.
I see I see... and thank you.
I was cheating - just getting the active record from the grid (it's configured for single-select). I did add your call thusly -
private void Processor_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
DataRecordPresenter drp = Infragistics.Windows.Utilities.GetAncestorFromType(e.OriginalSource as DependencyObject, typeof(DataRecordPresenter), false) as DataRecordPresenter;
...
[it's hard to squish code in this narrow format :-)]
This does the trick, but I'm still checking the active record for null for two reasons: 1) when the grid is loading the "SelectedItemChanged" method fires - which is okay and not unexpected, it's just that I'm not interested in the event unless there's an active record 2) as a just-in-case.
Many thanks - you guys are very helpful.