是否有WPF的UIElement的唯一标识符? [英] Is there any unique identifier for wpf UIElement?
问题描述
有关在我的WPF的形式记录用户的行为,我添加了一些全球性的事件处理程序
For logging user actions in my WPF forms, I added some global event handlers
我想到底是哪控制火灾事件日志,是有一些独特的标识符一个WPF 的UIElement
像客户端Id在ASP.Net?
I want to log exactly which control fire the event, is there some unique identifier for a wpf UIElement
like ClientId in ASP.Net?
推荐答案
看来我发现回答我的问题,答案是没有,现在的方式来做到这一点,正如MSDN指出这里(http://msdn.microsoft.com/en-us/magazine/dd483216.aspx)
Seems I found answer to my question, the answer is No, now way to do that, As noted in MSDN here (http://msdn.microsoft.com/en-us/magazine/dd483216.aspx)
请注意顶级窗口控件定义不包含
Name属性。这是因为显著,因为我们很快就会看到,
,当你写测试自动化,一个简单的方法来获得使用穆亚库访问的AutomationID属性
控制的引用,$ B $这是由从控件的名称属性编译器生成湾没有XAML名称属性
控制不会收到
的AutomationID财产。这样的想法是
考虑的事情
应用程序设计问题,如安全性,可扩展性和测试自动化的重要性的一个具体的,低层次的例子。
Notice that the top-level Window control definition does not contain a Name attribute. This is significant because, as we'll see shortly, when you write test automation, an easy way to get a reference to a control using the MUIA library is to access the AutomationId property, which is generated by the compiler from the control's Name attribute. Controls without a XAML Name attribute will not receive an AutomationId property. This idea is a specific, low-level example of the importance of considering application design issues for things such as security, extensibility, and test automation.
这篇关于是否有WPF的UIElement的唯一标识符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!