.NET Framework 4.6 and 4.5
Gets or sets the single child of a Viewbox element.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
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 Dim myViewbox As New Viewbox() myViewbox.StretchDirection = StretchDirection.Both myViewbox.Stretch = Stretch.Fill myViewbox.MaxWidth = 400 myViewbox.MaxHeight = 400 ' Create a new Grid that is hosted in the Viewbox Dim myGrid As New Grid() ' Create an Ellipse that is also hosted in the Grid Dim myEllipse As New Ellipse() myEllipse.Stroke = Brushes.RoyalBlue myEllipse.Fill = Brushes.LightBlue ' Create a TextBlock that is also hosted in the Grid Dim myTextBlock As 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)