0

Is there a possibility to call the Click-Event of a ListViewColumnHeader programatically?

I try to write an integration test about sortable columns in a ListView with a GridView and want to do something like this:

var list = new ListView();
var grid = new GridView();
var column = new GridViewColumn();
var header = new GridViewColumnHeader();
column.Header = header;
grid.Columns.Add(column);
header.DoClick(); // <-- not possible directly - what can I do

I already tried to achieve the goal by using the GridViewColumnHeaderAutomationPeer but did not succeed.

scher
  • 1,813
  • 2
  • 18
  • 39

1 Answers1

0

It is possible to Raise the Click event with the following line of code.

list.RaiseEvent(new RoutedEventArgs(GridViewColumnHeader.ClickEvent, header));
scher
  • 1,813
  • 2
  • 18
  • 39