DataGridColumnHeader has event MouseLeftButtonDown. How can i use this event ?
How can i join DataGridColumnHeader with DataGridColumn ?
for Example:
...
DataGridTextColumn TC;
TC = new DataGridTextColumn();
TC.Header = "ID";
TC.Binding = new Binding();
TC.Binding.Converter = new MyCustomConverter();
TC.Binding.ConverterParameter = 0;
// I need something like this:
TC.MouseLeftButtonDown += new event ....
// i need - when click on column header, my custom function will executed.
dataGrid.Columns.Add( TC );
worst code i have ever seen;) sry u should use a method(callback)/lambda sure satisfies an event delegate signature to handle the event
Callback approach:
TC.MouseLeftButtonDown += MouseLeftButtonDownHandler;
//define callback
private void MouseLeftButtonDownHandler(object sender, MouseButtonEventArgs mouseButtonEventArgs)
{
//write ur logic here...
}
Lambda approach
TC.MouseLeftButtonDown += (sender, args) => {//write ur logic here}
//where "sender" means the object raises the event(i.e. "TC"), args - object contains some helpfull information about the happened event(like "ClickCount", etc.).
This links will be usefull: