After the XamDataGrid is completely loaded I want to un-wire the DataRecordPresenter loaded event. I tried un-handling the event within the handler iteself but that does not work.
private void CashParameterGrid_DataRecordPresenter_Loaded(object sender, RoutedEventArgs e) { DataRecordPresenter presenter = sender as DataRecordPresenter; presenter.Loaded -= CashParameterGrid_DataRecordPresenter_Loaded; // dosent work
Hello Sam,
Thank you for your post. I have been looking into it and the code you have provided and it seems like that everything works ok on my side. I suppose you use a Style for the DataRecordPresenter and you added an EventSetter for the Loaded event. If so, your code won’t work, because if the Loaded event fires again it means that the Style will apply again and the handler will handle the event. I can suggest you create two identical Styles with Keys and remove the EventSetter in the second one and set it to the DataRecordPresenterStyle Property of the XamDataGrid’s FieldLayoutSettings, because you are not able to remove Setters from an existing Style. I attached a sample project showing this approach. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Stephen, thank you for your answer. Unfortunately, un-wiring the event the way you proposes causes the combo property and the datacontext propery of my xamcomboeditor to be null. Please see comments in attached solution file.
Thanks
Sam
I have modified the sample, so now I set the new Style to the DataRecordPresenter in the XamComboEditor’s Unloaded, because if it wasn’t fired the Loaded event cannot be fired again.
Hope this helps you.