Viewbox.Child Property
.NET Framework 3.0
Gets or sets the single child of a Viewbox element.
Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
/** @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)
<object> <object.Child> <UIElement .../> </object.Child> </object>
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 myGrid.Children.Add(myEllipse); myGrid.Children.Add(myTextBlock); // 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); myCanvas.Children.Add(myViewbox);
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.