-2

我有以下代码使用 WPF Path 对象。我从有很多免费图标的 Syncfusion MetroStudio 2 获得几何数据。但是,每当我尝试使用它们时,它们都会被切断。下面的图标应该显示房子,但在下面的边界内被切断。我的路径有问题吗?

<Grid>
  <Grid.Resources>
     <Geometry x:Key="HomeGeometry">M31.427,15.523L53.103,34.871 53.103,59.723C53.088,60.666 52.466,61.263 51.961,61.544 51.426,61.845 50.850,61.972 50.232,61.976L38.688,61.976C38.290,61.976 37.902,61.821 37.619,61.544 37.340,61.272 37.179,60.890 37.179,60.502L37.179,48.548 25.677,48.548 25.677,60.502C25.677,60.890 25.514,61.272 25.235,61.544 24.953,61.821 24.564,61.976 24.167,61.976L12.622,61.976C12.008,61.972 11.428,61.845 10.895,61.544 10.390,61.263 9.767,60.666 9.752,59.723L9.752,34.871z M31.430,0C32.412,0,33.395,0.347,34.172,1.042L61.536,25.469C63.191,26.947 63.306,29.454 61.791,31.072 60.273,32.685 57.703,32.796 56.048,31.319L31.427,9.342 6.806,31.319C6.024,32.015 5.043,32.358 4.067,32.358 2.964,32.358 1.868,31.925 1.065,31.072L1.062,31.066C-0.447,29.454,-0.335,26.945,1.319,25.469L28.686,1.042C29.464,0.347,30.447,0,31.430,0z
     </Geometry>
  </Grid.Resources>
  <Border
     Width="50" BorderBrush="LightBlue"
     Height="50" BorderThickness="2"
     HorizontalAlignment="Stretch"
     VerticalAlignment="Stretch"
     Focusable="False">
     <Path Data="{StaticResource HomeGeometry}" Fill="Red"/>
  </Border>

4

2 回答 2

3

我想你想要的是

...
<Path Data="{StaticResource HomeGeometry}" Fill="Red" Stretch="Uniform"/>
...
于 2013-03-21T17:52:10.580 回答
1

在此处输入图像描述

如我们所见,您的边框设置为 Width=50 和 Height=50,我们清楚地看到您的图标比那个大。

您的代码应该是:

<Border
  Width="64" BorderBrush="LightBlue"
  Height="64" BorderThickness="2"
  HorizontalAlignment="Stretch"
  VerticalAlignment="Stretch"
  Focusable="False">
  <Path Data="{StaticResource HomeGeometry}" Fill="Red"/>
</Border>

编辑:

或者,如果您希望您的图标为 50x50,请执行“500 - internal..”所说的操作,它会通过添加 Stretch="Uniform" 将您的图标拉伸到 50x50

于 2013-03-21T17:53:17.813 回答