다음을 통해 공유


Viewbox.Child 속성

정의

Viewbox 요소의 단일 자식 요소를 가져오거나 설정합니다.

public:
 virtual property System::Windows::UIElement ^ Child { System::Windows::UIElement ^ get(); void set(System::Windows::UIElement ^ value); };
public override System.Windows.UIElement Child { get; set; }
member this.Child : System.Windows.UIElement with get, set
Public Overrides Property Child As UIElement

속성 값

UIElement

Viewbox 요소의 단일 자식 요소입니다. 이 속성에는 기본값이 없습니다.

예제

다음 예제에는 인스턴스를 만드는 방법을 보여 줍니다는 Viewbox 다음 코드를 사용 하 여 해당 자식 속성을 설정 합니다.



// Create a Viewbox and add it to the Canvas
myViewbox = gcnew 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 = gcnew Grid();

// Create an Ellipse that will be hosted inside the Viewbox
myEllipse = gcnew Ellipse();
myEllipse->Stroke = Brushes::RoyalBlue;
myEllipse->Fill = Brushes::LightBlue;

// Create an TextBlock that will be hosted inside the Viewbox
myTextBlock = gcnew 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);


// 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);


' 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)

설명

추가 자식 요소를 추가 하는 경우는 Viewbox 발생을 ArgumentException 런타임 시.

적용 대상