本文整理汇总了C#中System.Windows.FrameworkElement.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.ApplyTemplate方法的具体用法?C# FrameworkElement.ApplyTemplate怎么用?C# FrameworkElement.ApplyTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElement
的用法示例。
在下文中一共展示了FrameworkElement.ApplyTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDescendantByName
public static Visual GetDescendantByName(FrameworkElement element, string name)
{
if (element == null)
{
return null;
}
if (element.Name == name)
{
return element;
}
Visual descendantByName = null;
if (element != null)
{
element.ApplyTemplate();
}
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++)
{
Visual child = VisualTreeHelper.GetChild(element, i) as Visual;
descendantByName = GetDescendantByName((FrameworkElement) child, name);
if (descendantByName != null)
{
return descendantByName;
}
}
return descendantByName;
}
示例2: OpenParentRibbonGroupDropDownSync
public static void OpenParentRibbonGroupDropDownSync(FrameworkElement fe, bool templateApplied)
{
if (!templateApplied)
{
// Apply template if not yet applied.
fe.ApplyTemplate();
}
// Get the Parent RibbonGroup and open its dropdown if needed.
RibbonGroup ribbonGroup = TreeHelper.FindAncestor(fe, delegate(DependencyObject element) { return (element is RibbonGroup); }) as RibbonGroup;
if (ribbonGroup == null)
{
ribbonGroup = TreeHelper.FindLogicalAncestor<RibbonGroup>(fe);
}
if (ribbonGroup != null &&
ribbonGroup.IsCollapsed &&
!ribbonGroup.IsDropDownOpen)
{
ribbonGroup.IsDropDownOpen = true;
fe.UpdateLayout();
}
}