WPF ListBox的自动化在.NET 4.0中失败 [英] Automation of WPF ListBox fails in .NET 4.0

查看:109
本文介绍了WPF ListBox的自动化在.NET 4.0中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用UI自动化来自动化WPF列表框的一个或多个框.

I'm using UI automation to automate a ou of the box WPF list box.

从.NET 4.0开始,无法通过其索引访问某个列表框项目,因为仅存在代表该列表框当前可见和选定项目的UI自动化元素.

Since .NET 4.0 it is not possible to access a certain list box item by its index, since only the UI automation elements representing the currently visible and selected items of the list box are present.

由于没有自动模式来获取项目总数或项目的适当索引,因此不可能通过索引获取适当的项目.

Since there are no automation patterns to obtain the total number of items or the appropriate index of an item there is no possibility to obtain the appropriate item by index.

在.NET 3.5中,列表框中的所有项目都表示为UI自动化元素,因此有可能破坏总数和索引.

In .NET 3.5 all items in the list box where represented as UI automation elements so there was a possibility to obtaion the total count and the index.

其他WPF控件,例如网格或以网格模式的列表视图提供适当的模式.

Other WPF controls like the grid  or the list view in grid mode provide the appropriate patterns.

为什么列表框不支持这些模式?

Why these patterns are not supported for the list box?

有人有解决这个问题的想法吗?

Has anybody an idea to solve this problem?

致谢

拉斯·阿勒海格

 

 

 

 

推荐答案

Hi

在Wpf 4.0中,列表框已开始实现Virtualizeditempattern和itemcontainerPattern.您需要使用它们来使事情正常工作

With Wpf 4.0 listbox has started implementing Virtualizeditempattern and itemcontainerPattern. You need to use these to make things work

这些链接是

http://msdn.microsoft.com/en-us/library /system.windows.automation.itemcontainerpattern.aspx

http://msdn.microsoft.com/en-us/library /system.windows.automation.virtualizeditempattern.aspx

 


这篇关于WPF ListBox的自动化在.NET 4.0中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆