다음을 통해 공유


Panel.ZIndex 연결된 속성

정의

요소가 표시되는 z 평면의 순서를 나타내는 값을 가져오거나 설정합니다.

see GetZIndex, and SetZIndex
see GetZIndex, and SetZIndex
see GetZIndex, and SetZIndex

예제

다음 예제에서는 XAML(Extensible Application Markup Language) 및 코드를 사용하여 속성 값을 ZIndex 설정하는 방법을 보여 줍니다.


// Create the application's main window
mainWindow = gcnew Window();
mainWindow->Title = "Canvas ZIndex Sample";

// Create the Canvas
myCanvas = gcnew Canvas();

// Create the child Rectangle elements
myRectangle1 = gcnew Rectangle();
myRectangle2 = gcnew Rectangle();
myRectangle3 = gcnew Rectangle();
myRectangle4 = gcnew Rectangle();
myRectangle5 = gcnew Rectangle();
myRectangle6 = gcnew Rectangle();

// Set properties on the Rectangle elements
Canvas::SetTop(myRectangle1, 100);
Canvas::SetLeft(myRectangle1, 100);
Canvas::SetZIndex(myRectangle1, 3);
myRectangle1->Fill = Brushes::Blue;
myRectangle1->Width = 100;
myRectangle1->Height = 100;

Canvas::SetTop(myRectangle2, 150);
Canvas::SetLeft(myRectangle2, 150);
Canvas::SetZIndex(myRectangle2, 1);
myRectangle2->Fill = Brushes::Yellow;
myRectangle2->Width = 100;
myRectangle2->Height = 100;

Canvas::SetTop(myRectangle3, 200);
Canvas::SetLeft(myRectangle3, 200);
Canvas::SetZIndex(myRectangle3, 2);
myRectangle3->Fill = Brushes::Green;
myRectangle3->Width = 100;
myRectangle3->Height = 100;

Canvas::SetTop(myRectangle4, 300);
Canvas::SetLeft(myRectangle4, 200);
Canvas::SetZIndex(myRectangle4, 1);
myRectangle4->Fill = Brushes::Green;
myRectangle4->Width = 100;
myRectangle4->Height = 100;

Canvas::SetTop(myRectangle5, 350);
Canvas::SetLeft(myRectangle5, 150);
Canvas::SetZIndex(myRectangle5, 3);
myRectangle5->Fill = Brushes::Yellow;
myRectangle5->Width = 100;
myRectangle5->Height = 100;

Canvas::SetTop(myRectangle6, 400);
Canvas::SetLeft(myRectangle6, 100);
Canvas::SetZIndex(myRectangle6, 2);
myRectangle6->Fill = Brushes::Blue;
myRectangle6->Width = 100;
myRectangle6->Height = 100;

// Add the Rectangles to the Canvas' Children collection
myCanvas->Children->Add(myRectangle1);
myCanvas->Children->Add(myRectangle2);
myCanvas->Children->Add(myRectangle3);
myCanvas->Children->Add(myRectangle4);
myCanvas->Children->Add(myRectangle5);
myCanvas->Children->Add(myRectangle6);

// Add the Canvas as the Content of the parent Window Object
mainWindow->Content = myCanvas;
mainWindow->Show();

// Create the application's main window
mainWindow = new Window ();
mainWindow.Title = "Canvas ZIndex Sample";

// Create the Canvas
myCanvas = new Canvas();

// Create the child Rectangle elements
myRectangle1 = new Rectangle();
myRectangle2 = new Rectangle();
myRectangle3 = new Rectangle();
myRectangle4 = new Rectangle();
myRectangle5 = new Rectangle();
myRectangle6 = new Rectangle();

// Set properties on the Rectangle elements
Canvas.SetTop(myRectangle1, 100);
Canvas.SetLeft(myRectangle1, 100);
Canvas.SetZIndex(myRectangle1, 3);
myRectangle1.Fill = Brushes.Blue;
myRectangle1.Width = 100;
myRectangle1.Height = 100;

Canvas.SetTop(myRectangle2, 150);
Canvas.SetLeft(myRectangle2, 150);
Canvas.SetZIndex(myRectangle2, 1);
myRectangle2.Fill = Brushes.Yellow;
myRectangle2.Width = 100;
myRectangle2.Height = 100;

Canvas.SetTop(myRectangle3, 200);
Canvas.SetLeft(myRectangle3, 200);
Canvas.SetZIndex(myRectangle3, 2);
myRectangle3.Fill = Brushes.Green;
myRectangle3.Width = 100;
myRectangle3.Height = 100;

Canvas.SetTop(myRectangle4, 300);
Canvas.SetLeft(myRectangle4, 200);
Canvas.SetZIndex(myRectangle4, 1);
myRectangle4.Fill = Brushes.Green;
myRectangle4.Width = 100;
myRectangle4.Height = 100;

Canvas.SetTop(myRectangle5, 350);
Canvas.SetLeft(myRectangle5, 150);
Canvas.SetZIndex(myRectangle5, 3);
myRectangle5.Fill = Brushes.Yellow;
myRectangle5.Width = 100;
myRectangle5.Height = 100;

Canvas.SetTop(myRectangle6, 400);
Canvas.SetLeft(myRectangle6, 100);
Canvas.SetZIndex(myRectangle6, 2);
myRectangle6.Fill = Brushes.Blue;
myRectangle6.Width = 100;
myRectangle6.Height = 100;

// Add the Rectangles to the Canvas' Children collection
myCanvas.Children.Add(myRectangle1);
myCanvas.Children.Add(myRectangle2);
myCanvas.Children.Add(myRectangle3);
myCanvas.Children.Add(myRectangle4);
myCanvas.Children.Add(myRectangle5);
myCanvas.Children.Add(myRectangle6);

// Add the Canvas as the Content of the parent Window Object
mainWindow.Content = myCanvas;
mainWindow.Show ();
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" WindowTitle="ZIndex Sample">
  <Canvas>
    <Rectangle Canvas.ZIndex="3" Width="100" Height="100" Canvas.Top="100" Canvas.Left="100" Fill="blue"/>
    <Rectangle Canvas.ZIndex="1" Width="100" Height="100" Canvas.Top="150" Canvas.Left="150" Fill="yellow"/>
    <Rectangle Canvas.ZIndex="2" Width="100" Height="100" Canvas.Top="200" Canvas.Left="200" Fill="green"/>

    <!-- Reverse the order to illustrate z-index property -->

    <Rectangle Canvas.ZIndex="1" Width="100" Height="100" Canvas.Top="300" Canvas.Left="200" Fill="green"/>
    <Rectangle Canvas.ZIndex="3" Width="100" Height="100" Canvas.Top="350" Canvas.Left="150" Fill="yellow"/>
    <Rectangle Canvas.ZIndex="2" Width="100" Height="100" Canvas.Top="400" Canvas.Left="100" Fill="blue"/>
  </Canvas>
</Page>

설명

큼를 value 의 지정 element가능성이 높습니다는 element 전경에 표시 하는 것입니다. 마찬가지로, 경우는 element 에 상대적으로 낮은 value, element 백그라운드에서 나타날 수 있습니다. 예를 들어는 element 있는 value 5의 위에 표시 됩니다는 element 있는 value 위에 표시 되는 4는 element 3의 값이 있는 합니다. 음수 값이 허용 하 고이 우선 순위 패턴을 계속 합니다.

멤버는 Children 같으면 해당 컬렉션 ZIndex 값은 시각적 트리에 나타나는 순서로 렌더링 됩니다. 멤버를 반복 하 여 자식의 인덱스 위치를 확인할 수 있습니다는 Children 컬렉션입니다.

종속성 속성 정보

식별자 필드 ZIndexProperty
메타 데이터 속성 설정 true 없음

적용 대상