Display DrawingBrush in canvas and keeping his proportions

1k Views Asked by At

I use the SharpVector to convert icon.svg to icon.xaml. This program generate a DrawingBrush like :

<DrawingBrush x:Key="Plus">
<DrawingBrush.Drawing>
    <DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <DrawingGroup x:Name="DrawingLayer">
        <DrawingGroup.ClipGeometry>
          <RectangleGeometry Rect="0,0,88.582672,88.582672" />
        </DrawingGroup.ClipGeometry>
        <GeometryDrawing x:Name="path3767" Brush="#FF4D4D4D">
          <GeometryDrawing.Geometry>
            <PathGeometry FillRule="Nonzero" Figures="M36.512901,88.58266L36.512901,51.833165 8.88026306711254E-07,51.833165 8.88026306711254E-07,36.47519 36.512901,36.47519 36.512901,-1.76623310039759E-05 52.069777,-1.76623310039759E-05 52.069777,36.47519 88.582677,36.47519 88.582677,51.833165 52.069777,51.833165 52.069777,88.58266z" />
          </GeometryDrawing.Geometry>
        </GeometryDrawing>
      </DrawingGroup>
    </DrawingGroup>
</DrawingBrush.Drawing>

for all my icons. But now i want to display my DrawingBrush in a Canvas.Background, it's ok with that :

<Grid Background="{DynamicResource Plus}" Height="200" Width="200" Margin="5">

But i want to keep picture proportions stock in the Rectangle Geometry, for example here Rect="0,0,88.582672,88.582672".

How i can do that?

Gat

1

There are 1 best solutions below

0
On

Try setting the Stretch property of DrawingBrush to uniform:

<DrawingBrush x:Key="Plus" Stretch="Uniform"> 
...