0

I have a WPF application where I need to work on datagrid ,in column header I have added image button to each column which when clicked should pop up with that specific column name and other details. Currently I have done this:

void data1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
 {
    EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent, new     RoutedEventHandler(btnFilterImage_Click) );
  }


 private void btnFilterImage_Click(object sender, RoutedEventArgs e)      
 {
     viewModel.OnYieldDistinctValues(reportDatagrid.Columns.ToString());
     lstYield.ItemsSource = viewModel.TextFilters;
     popYield.Placement = PlacementMode.MousePoint;
     popYield.IsOpen = true;
 }

My question is how can I get the particular column name in btnFilterImage_Click. Please help.!!

Thanks!!

suu
  • 155
  • 2
  • 9

1 Answers1

1

Cast sender to Button and find its VisualParent using FindVisualParent till you get column.

Community
  • 1
  • 1
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208