c#,UI自动化:双击WPF datagrid行 [英] c#,Ui automation : double click on WPF datagrid row
本文介绍了c#,UI自动化:双击WPF datagrid行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想使用外部程序(控制台应用程序)模拟双击数据网格上的一行.我到处搜索,但找不到清晰的答案:(
I want to simulate a double click on a row on a data grid using an external program (console application). I searched every where but I cannot find a clear answer :(
有人可以帮助我吗?
致谢.
推荐答案
一旦您引用了DataGrid及其DataGridRow元素,就可以以编程方式双击一行通过引发MouseDoubleClick事件:
Once you have a reference to the DataGrid and one its DataGridRow elements, you could programmatically double click a row by raising a MouseDoubleClick event:
DataGrid dataGrid = nameOfYourGrid;
DataGridRow row = dataGrid.ItemContainerGenerator.ContainerFromIndex(0) as DataGridRow; //first row
MouseButtonEventArgs args = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left) { RoutedEvent = Control.MouseDoubleClickEvent };
row.RaiseEvent(args);
这篇关于c#,UI自动化:双击WPF datagrid行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文