在WPF中设置RectangleGeometry的背景图像?

时间:2013-05-19 13:02:43

标签: wpf image background rectangles

我有这段代码:

<Path Fill="Brown">
  <Path.Data>
    <RectangleGeometry x:Name="rec"
                       RadiusX="0"
                       RadiusY="20"
                       Rect="410,135,60,25"></RectangleGeometry>
  </Path.Data>
</Path>

如何为此Image设置背景Rectangle

1 个答案:

答案 0 :(得分:1)

您可以使用ImageBrush作为路径的Fill属性:

<Path>
    <Path.Fill>
        <ImageBrush ImageSource="..."/>
    </Path.Fill>
    <Path.Data>
        <RectangleGeometry x:Name="rec" RadiusX="0" RadiusY="20" Rect="410,135,60,25"></RectangleGeometry>
    </Path.Data>
</Path>