Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

MouseBinding defined in code

$
0
0

I am trying to insert a textblock into the column header of a datagrid when autogeneratecolumns="true".  I have the following but when I have set a beakpoint in OnColumnHeaderClick the object is null.  I was hoping to get either the textblock object that was clicked or a MouseEventArgs.

public ICommand ColumnHeaderClickCommand { get; private set; } private void dataGrid1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) { var textblock = new TextBlock(); textblock.Text = e.Column.Header.ToString(); textblock.HorizontalAlignment = HorizontalAlignment.Stretch; textblock.VerticalAlignment = VerticalAlignment.Stretch; textblock.InputBindings.Add(new MouseBinding(ColumnHeaderClickCommand, new MouseGesture() { MouseAction = MouseAction.LeftClick })); e.Column.Header = textblock; } private void OnColumnHeaderClick(object obj) { }



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>