I have a DataGrid with one column that is numeric and editable. I have a handler set on XamNumericEditor.EditModeModeStarting, but I must not be doing it correctly, because my event handler is not being invoked.
The intention here is that whenever the user clicks to edit the field, the field is first set to the current value of another constantly-updating field (a stock price), which the user an then edit further if they wish.
Here's the XAML for the column. Can someone point out where I'm going wrong? Much appreciated.
<igDP:Field Name="LimitPrice" Label="Limit Price"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="True"> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <EventSetter Event="igEditors:XamNumericEditor.EditModeStarting" Handler="limitPrice_OnEditModeStarting"/> </Style> </igDP:FieldSettings.CellValuePresenterStyle> <igDP:FieldSettings.EditorStyle> <!-- (only cosmetic effects here) --> <Style TargetType="{x:Type igEditors:XamNumericEditor}"> <Setter Property="Background" Value="{StaticResource editable}"/> <Setter Property="Mask" Value="{StaticResource NoDollarSignMask}"/> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
Oh, also, I removed the CellValuePresenterStyle entirely from the initial xaml that I posted. It was part of my non-working initial attempt, and wasn't doing anything.
Thanks. Your second option got me where I needed to be.
First, I added an "EditModeStarted" handler to my XamDataGrid xaml declaration.
And the handler is as follows:
private void grid_EditModeStarted(object sender, Infragistics.Windows.DataPresenter.Events.EditModeStartedEventArgs e) { DependencyObject source = e.OriginalSource as DependencyObject; if (source == null) return; if (e.Cell.Field.Name == "LimitPrice") e.Editor.Value = e.Cell.Record.Cells["Last"].Value; }
I believe the event is going to be handled by the DataPresenter and so the setter would not be invoked by default so you could try setting the HandledEventsToo of the EventSetter to true. Another option is to handle the datapresenter's EditModeStarted event and initialize the Value of the e.Editor if the e.Cell.Field.Name is "LimitPrice".
Does anyone have any ideas? The inability to set events on this column is blocking my ability to implement a customer requirement.
This has to be possible, I just haven't been able to figure it out.
Thanks if anyone can provide any help.