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


C# UIElement.FindElementInNamescope方法代码示例

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


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

示例1: GetRoutedEvent

    private RoutedEvent GetRoutedEvent(UIElement element, out UIElement targetObject)
    {
      if (string.IsNullOrEmpty(TargetName))
      {
        targetObject = element;
      }
      else
      {
        // Search the element in "normal" name scope and in the dynamic structure via the FindElement method
        // I think this is more than WPF does. It makes it possible to find elements instantiated
        // by a template, for example.
        targetObject = (element.FindElementInNamescope(TargetName) ??
            element.FindElement(new NameMatcher(TargetName))) as UIElement;
        if (targetObject == null)
          return null;
      }

      var routedEvent = _routedEvent;
      if (routedEvent == null)
      {
        // the routed event is not set already, so we try to get it from the targetObject
        return EventManager.GetRoutedEventForOwner(targetObject.GetType(), Event, true);
      }
      return routedEvent;
    }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:25,代码来源:EventSetter.cs

示例2: FindPropertyDescriptor

 protected bool FindPropertyDescriptor(UIElement element,
     out IDataDescriptor propertyDescriptor, out DependencyObject targetObject)
 {
   string targetName = TargetName;
   propertyDescriptor = null;
   if (string.IsNullOrEmpty(targetName))
     targetObject = element;
   else
   {
     // Search the element in "normal" namescope and in the dynamic structure via the FindElement method
     // I think this is more than WPF does. It makes it possible to find elements instantiated
     // by a template, for example.
     targetObject = element.FindElementInNamescope(targetName) ??
         element.FindElement(new NameMatcher(targetName));
     if (targetObject == null)
       return false;
   }
   string property = Property;
   int index = property.IndexOf('.');
   if (index != -1)
   {
     string propertyProvider = property.Substring(0, index);
     string propertyName = property.Substring(index + 1);
     DefaultAttachedPropertyDataDescriptor result;
     if (!DefaultAttachedPropertyDataDescriptor.CreateAttachedPropertyDataDescriptor(new MpfNamespaceHandler(),
         element, propertyProvider, propertyName, out result))
     {
       ServiceRegistration.Get<ILogger>().Warn(
           string.Format("Attached property '{0}' cannot be set on element '{1}'", property, targetObject));
       return false;
     }
     propertyDescriptor = result;
     return true;
   }
   else
   {
     string propertyName = property;
     IDataDescriptor result;
     if (!ReflectionHelper.FindMemberDescriptor(targetObject, propertyName, out result))
     {
       ServiceRegistration.Get<ILogger>().Warn(
           string.Format("Property '{0}' cannot be set on element '{1}'", property, targetObject));
       return false;
     }
     propertyDescriptor = result;
     return true;
   }
 }
开发者ID:HeinA,项目名称:MediaPortal-2,代码行数:48,代码来源:SetterBase.cs


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