本文整理匯總了C#中System.Windows.Controls.Viewbox.Child屬性的典型用法代碼示例。如果您正苦於以下問題:C# Viewbox.Child屬性的具體用法?C# Viewbox.Child怎麽用?C# Viewbox.Child使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Controls.Viewbox
的用法示例。
在下文中一共展示了Viewbox.Child屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Viewbox
// 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);