在画布上显示DrawingBrush并保持其比例



我使用SharpVector将icon.svg转换为icon.xaml。这个程序生成一个类似DrawingBrush的:

<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>

我所有的图标。但现在我想在画布上显示我的DrawingBrush。背景,可以:

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

但我想在矩形几何体中保留图片比例,例如这里Rect="0,0,88.582672,88.582672"。

我该怎么做?

门控

尝试将DrawingBrush的Stretch属性设置为uniform:

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

相关内容

  • 没有找到相关文章

最新更新