我使用 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>
对于我所有的图标。但是现在我想在 Canvas.Background 中显示我的 DrawingBrush,这样就可以了:
<Grid Background="{DynamicResource Plus}" Height="200" Width="200" Margin="5">
但我想在矩形几何中保留图片比例,例如这里的 Rect="0,0,88.582672,88.582672"。
我怎么能这样做?
盖特