首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

WPF,AutomationProperties类伏什么作用的

2013-12-09 
WPF,AutomationProperties类起什么作用的?AutomationProperties类:MSDN为获取或设置 AutomationPeer 元素

WPF,AutomationProperties类起什么作用的?
AutomationProperties类:MSDN为获取或设置 AutomationPeer 元素实例的相关属性值提供了一种途径。

比如在标准的ScrollViewer控件模板中,出现有以下这个滚动条:


<ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1"
                   Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding
                  ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" 
                   ViewportSize="{TemplateBinding ViewportHeight}"/>


这里面的AutomationProperties.AutomationId="VerticalScrollBar"怎么理解呢?
[解决办法]
AutomationPeer是自动化UI测试框架相关的
http://www.marcwils.be.eu.org/posts/implementing-a-ui-automationpeer-for-your-wpf-custom-control
可以看看这篇文章,也有demo下载
[解决办法]
这些应该是属于UI自动化的知识,你查找下吧
[解决办法]
嗯,UI Automation。UI Automation允许程序模拟人工去操作一个用户界面来执行程序。
[解决办法]
你这段代码我找到出处了,下载看了一下
AutomationProperties.AutomationId="VerticalScrollBar"
这句去掉丝毫不见影响
msdn的介绍更像是说模拟操作,自动化测试
很可惜只找到了一段模拟鼠标点击的代码(与AutomationProperties相同的命名空间)

ButtonAutomationPeer bap = new ButtonAutomationPeer(btn);
IInvokeProvider iip = bap.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
iip.Invoke();

因为设计者是为了做UI样式,所以我觉着下面这个链接还是比较靠谱的
http://social.msdn.microsoft.com/Forums/silverlight/zh-CN/cb7141c5-a045-405e-ac56-be027de72aed/automationpropertiessetname-?forum=wpfzhchs

热点排行