c# - How to get a DataGrid column name when the header is clicked, WPF -
i trying determine column name of clicked column using following event handler.
here xaml:
<datagrid name ="loggedgrid" horizontalalignment="left" margin="-3,288,0,0" verticalalignment="top" height="198" width="973"> <datagrid.columnheaderstyle> <style targettype="datagridcolumnheader"> <eventsetter event="click" handler="columnheader_click" /> </style> </datagrid.columnheaderstyle> </datagrid>
and here event handler, cannot figure out how determine column name after column has been clicked, ideas?
private void columnheader_click(object sender, routedeventargs e) { }
why not cast sender datagridcolumnheader , gets content this.
private void columnheader_click(object sender, routedeventargs e) { string header = ((datagridcolumnheader)sender).content.tostring(); }
Comments
Post a Comment