DrawingVisual.Drawing プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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 内の Drawing オブジェクトのコレクションを表す DrawingVisual 型の値を取得します。
例
次の例では、 DrawingGroup ホスト ビジュアル内の各 DrawingVisual の値が列挙されています。
// 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保持されません。