本文整理汇总了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;
}
示例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;
}
}