Skip to content

How to add Event Triggers for DetailsViewDataGrid in WPF DataGrid (SfDataGrid)?

Notifications You must be signed in to change notification settings

SyncfusionExamples/how-to-add-event-triggers-for-detailsviewdatagrid-in-wpf-datagrid

Repository files navigation

How to add Event Triggers for DetailsViewDataGrid in WPF DataGrid (SfDataGrid)?

About the sample

This example illustrates how to add Event Triggers for DetailsViewDataGrid in WPF DataGrid (SfDataGrid).

In WPF DataGrid (SfDataGrid), EventTriggers added for the DetailsView DataGrid which is defined within the SfDataGrid.DetailsViewDefinition in XAML will not work, as it is not the same UI element which is displayed as the child DataGrid. However, it is possible to add EventTrigger for the DetailsView DataGrid in code behind by using DetailsViewLoading event.

private void OnDataGrid_DetailsViewLoading(object sender, DetailsViewLoadingAndUnloadingEventArgs e)
{
    System.Windows.Interactivity.EventTrigger trigger = new System.Windows.Interactivity.EventTrigger();
    trigger.EventName = "CellTapped";

    InvokeCommandAction action = new InvokeCommandAction();
    action.Command = (this.DataContext as ViewModel).CellTappedCommand;

    trigger.Actions.Add(action);
    trigger.Attach(e.DetailsViewDataGrid);
}

KB article: How to add Event Triggers for DetailsViewDataGrid in WPF DataGrid (SfDataGrid)?

Requirements to run the demo

Visual Studio 2015 and above versions.

About

How to add Event Triggers for DetailsViewDataGrid in WPF DataGrid (SfDataGrid)?

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages