Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3160
How to un-wire DataRecordPresenter loaded event?
posted

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

 

Parents
  • 138253
    Offline posted

    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.

    DataRecordPresenterLoadedEvent.zip
Reply Children