当前位置: 首页>>代码示例>>C#>>正文


C# UIElement.CreateAutomationPeer方法代码示例

本文整理汇总了C#中System.Windows.UIElement.CreateAutomationPeer方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.CreateAutomationPeer方法的具体用法?C# UIElement.CreateAutomationPeer怎么用?C# UIElement.CreateAutomationPeer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.UIElement的用法示例。


在下文中一共展示了UIElement.CreateAutomationPeer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePeerForElement

 ///<summary>
 /// This static helper creates an AutomationPeer for the specified element and 
 /// caches it - that means the created peer is going to live long and shadow the
 /// element for its lifetime. The peer will be used by Automation to proxy the element, and
 /// to fire events to the Automation when something happens with the element.
 /// The created peer is returned from this method and also from subsequent calls to this method
 /// and <seealso cref="FromElement"/>. The type of the peer is determined by the 
 /// <seealso cref="UIElement.OnCreateAutomationPeer"/> virtual callback. If UIElement does not
 /// implement the callback, there will be no peer and this method will return 'null' (in other
 /// words, there is no such thing as a 'default peer').
 ///</summary>
 public static AutomationPeer CreatePeerForElement(UIElement element)
 {
     if(element == null)
     {
         throw new ArgumentNullException("element");
     }
     
     return element.CreateAutomationPeer();
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:20,代码来源:UIElementAutomationPeer.cs

示例2: CreatePeerForElement

		public static AutomationPeer CreatePeerForElement (UIElement element)
		{
			if (element == null)
				throw new ArgumentNullException ("element");
			if (element.AutomationPeer == null) {
				element.AutomationPeer = element.CreateAutomationPeer ();
				// We need to cache old values to raise PropertyChanged events
				// when calling AutomationPeer.InvalidatePeer()
				if (element.AutomationPeer != null)
					element.AutomationPeer.CacheMainProperties ();
			}
			return element.AutomationPeer;
		}
开发者ID:kangaroo,项目名称:moon,代码行数:13,代码来源:FrameworkElementAutomationPeer.cs


注:本文中的System.Windows.UIElement.CreateAutomationPeer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。