DrawingVisual.Drawing 속성

정의

DrawingVisual 개체의 그리기 내용을 가져옵니다.

public:
 property System::Windows::Media::DrawingGroup ^ Drawing { System::Windows::Media::DrawingGroup ^ get(); };
public System.Windows.Media.DrawingGroup Drawing { get; }
member this.Drawing : System.Windows.Media.DrawingGroup
Public ReadOnly Property Drawing As DrawingGroup

속성 값

DrawingGroup

DrawingGroup에서 Drawing 개체의 컬렉션을 나타내는 DrawingVisual 형식의 값을 가져옵니다.

예제

다음 예제에서는 DrawingGroup 각 값 DrawingVisual visual 열거 되는 호스트에서.

// Enumerate the DrawingVisual children of a host visual.
public void RetrieveDrawings(Visual visualHost)
{
    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(visualHost); i++)
    {
        // Retrieve child visual at specified index value.
        DependencyObject dependencyObject = VisualTreeHelper.GetChild(visualHost, i);

        // Determine if the child object is a DrawingVisual.
        if (dependencyObject.GetType() == typeof(DrawingVisual))
        {
            DrawingVisual drawingVisual = (DrawingVisual)dependencyObject;

            if (drawingVisual.Drawing != null)
            {
                if (drawingVisual.Drawing.GetType() == typeof(DrawingGroup))
                {
                    // Enumerate the drawings in the DrawingGroup.
                    EnumDrawingGroup(drawingVisual.Drawing);
                }
            }
        }
     }
 }

 // Enumerate the drawings in the DrawingGroup.
 public void EnumDrawingGroup(DrawingGroup drawingGroup)
 {
     DrawingCollection dc = drawingGroup.Children;

     // Enumerate the drawings in the DrawingCollection.
     foreach (Drawing drawing in dc)
     {
         // If the drawing is a DrawingGroup, call the function recursively.
         if (drawing.GetType() == typeof(DrawingGroup))
         {
             EnumDrawingGroup((DrawingGroup)drawing);
         }

         if (drawing.GetType() == typeof(GeometryDrawing))
         {
             // Perform action based on drawing type.
         }
     }
 }
' Enumerate the DrawingVisual children of a host visual.
Public Sub RetrieveDrawings(ByVal visualHost As Visual)
    For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(visualHost) - 1
        ' Retrieve child visual at specified index value.
        Dim dependencyObject As DependencyObject = VisualTreeHelper.GetChild(visualHost, i)

        ' Determine if the child object is a DrawingVisual.
        If dependencyObject.GetType() Is GetType(DrawingVisual) Then
            Dim drawingVisual As DrawingVisual = CType(dependencyObject, DrawingVisual)

            If drawingVisual.Drawing IsNot Nothing Then
                If drawingVisual.Drawing.GetType() Is GetType(DrawingGroup) Then
                    ' Enumerate the drawings in the DrawingGroup.
                    EnumDrawingGroup(drawingVisual.Drawing)
                End If
            End If
        End If
    Next i
End Sub

 ' Enumerate the drawings in the DrawingGroup.
 Public Sub EnumDrawingGroup(ByVal drawingGroup As DrawingGroup)
     Dim dc As DrawingCollection = drawingGroup.Children

     ' Enumerate the drawings in the DrawingCollection.
     For Each drawing As Drawing In dc
         ' If the drawing is a DrawingGroup, call the function recursively.
         If drawing.GetType() Is GetType(DrawingGroup) Then
             EnumDrawingGroup(CType(drawing, DrawingGroup))
         End If

         If drawing.GetType() Is GetType(GeometryDrawing) Then
             ' Perform action based on drawing type.
         End If
     Next drawing
 End Sub

설명

시각적 개체는 벡터 그래픽 명령 목록과 해당 렌더링 데이터를 저장합니다. 명령 목록의 각 항목에는 하위 수준 그래픽 데이터 직렬화 된 형식에서 집합을 나타냅니다. 어떻게 시각적 개체에 대 한 자세한 내용은 그래픽 데이터를 저장, 참조 WPF 그래픽 렌더링 개요합니다.

반환 된 변경 DrawingGroup 값으로 유지 되지 않습니다는 DrawingVisual합니다.

적용 대상