Copy as XAML - Use DrawingGroup instead of Canvas

The copy as XAML command is great but in some cases, we need the XAML as a DrawingImage element in order to use it as an image source.

Actual output:

<Canvas Width="32" Height="32" Background="#FFFFFF" ClipToBounds="True">

 <Rectangle  Width="32"  Height="32"  Fill="#FF0000" />

 <Path  Data="M1 21L1 0"  Stretch="Fill"  Canvas.Left="7.5"  Canvas.Top="5.5"  Width="2"  Height="21"  

StrokeThickness="1"  Stroke="#FFFF00" />

</Canvas>

Alternative output:

<DrawingGroup>

 <DrawingGroup.Children>

<GeometryDrawing Brush="#FFFF0000" Geometry="F1 M 0,0L 32,0L 32,32L 0,32L 0,0 Z "/>

  <GeometryDrawing Geometry="F1 M 7.5,5.5L 7.5,26.5">

<GeometryDrawing.Pen>

<Pen LineJoin="Round" Brush="#FFFFFF00"/>

</GeometryDrawing.Pen>

 </DrawingGroup.Children>

</DrawingGroup>

Tagged:
Sign In or Register to comment.