Viewbox.Child Property

Gets or sets the single child of a Viewbox element.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

public override UIElement Child { get; set; }
/** @property */
public UIElement get_Child ()

/** @property */
public void set_Child (UIElement value)

public override function get Child () : UIElement

public override function set Child (value : UIElement)

    <UIElement .../>

Property Value

The single child of a Viewbox element. This property has no default value.

If you add an additional child element to a Viewbox it causes an ArgumentException at run time.

The following example shows how to create an instance of a Viewbox and then set its child property by using code.

// Create a Viewbox and add it to the Canvas
myViewbox = new Viewbox();
myViewbox.StretchDirection = StretchDirection.Both;
myViewbox.Stretch = Stretch.Fill;
myViewbox.MaxWidth = 400;
myViewbox.MaxHeight = 400;

// Create a Grid that will be hosted inside the Viewbox
myGrid = new Grid();

// Create an Ellipse that will be hosted inside the Viewbox
myEllipse = new Ellipse();
myEllipse.Stroke = Brushes.RoyalBlue;
myEllipse.Fill = Brushes.LightBlue;

// Create an TextBlock that will be hosted inside the Viewbox
myTextBlock = new TextBlock();
myTextBlock.Text = "Viewbox";

// Add the children to the Grid

// Add the Grid as the single child of the Viewbox
myViewbox.Child = myGrid;

// Position the Viewbox in the Parent Canvas
Canvas.SetTop(myViewbox, 100);
Canvas.SetLeft(myViewbox, 100);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0