本文整理汇总了C#中System.Windows.Media.ContainerVisual.GetVisualChild方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerVisual.GetVisualChild方法的具体用法?C# ContainerVisual.GetVisualChild怎么用?C# ContainerVisual.GetVisualChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.ContainerVisual
的用法示例。
在下文中一共展示了ContainerVisual.GetVisualChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyContainerVisualHost
// Create a host visual derived from the FrameworkElement class.
// This class provides layout, event handling, and container support for
// the child visual objects.
public class MyContainerVisualHost : FrameworkElement
{
private ContainerVisual _containerVisual;
public MyContainerVisualHost(DrawingVisual border, DrawingVisual text)
{
// Create a ContainerVisual to hold DrawingVisual children.
_containerVisual = new ContainerVisual();
// Add children to ContainerVisual in reverse z-order (bottom to top).
_containerVisual.Children.Add(border);
_containerVisual.Children.Add(text);
// Create parent-child relationship with host visual and ContainerVisual.
this.AddVisualChild(_containerVisual);
}
// Provide a required override for the VisualChildrenCount property.
protected override int VisualChildrenCount
{
get { return _containerVisual == null ? 0 : 1; }
}
// Provide a required override for the GetVisualChild method.
protected override Visual GetVisualChild(int index)
{
if (_containerVisual == null)
{
throw new ArgumentOutOfRangeException();
}
return _containerVisual;
}
}