本文整理汇总了C#中System.Windows.Media.Visual.AddVisualChild方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.AddVisualChild方法的具体用法?C# Visual.AddVisualChild怎么用?C# Visual.AddVisualChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了Visual.AddVisualChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyVisualHost
// Create a host visual derived from the FrameworkElement class.
// This class provides layout, event handling, and container support for
// the child visual object.
public class MyVisualHost : FrameworkElement
{
private DrawingVisual _child;
public MyVisualHost(DrawingVisual drawingVisual)
{
_child = drawingVisual;
this.AddVisualChild(_child);
}
public DrawingVisual Child
{
get
{
return _child;
}
set
{
if (_child != value)
{
this.RemoveVisualChild(_child);
_child = value;
this.AddVisualChild(_child);
}
}
}
// Provide a required override for the VisualChildrenCount property.
protected override int VisualChildrenCount
{
get { return _child == null ? 0 : 1; }
}
// Provide a required override for the GetVisualChild method.
protected override Visual GetVisualChild(int index)
{
if (_child == null)
{
throw new ArgumentOutOfRangeException();
}
return _child;
}