///<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();
 }
		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;
		}