Wpf 为网格背景使用DrawingBrush资源

Wpf 为网格背景使用DrawingBrush资源,wpf,xaml,Wpf,Xaml,我试图将UniformGrid的背景设置为DrawingBrush资源,但出现了一个错误。我如何做到这一点: <UniformGrid Rows="1" Columns="1" Height="75" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Grid.Row="2"> <UniformGrid.Background> <DrawingBrush="{

我试图将UniformGrid的背景设置为DrawingBrush资源,但出现了一个错误。我如何做到这一点:

  <UniformGrid Rows="1" Columns="1" Height="75" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Grid.Row="2">
        <UniformGrid.Background>
            <DrawingBrush="{StaticResource SteelBrush_Vert}"/>
        </UniformGrid.Background>
错误:缺少空白

这是我正在尝试使用的钢结构:

 <DrawingBrush x:Key="SteelBrush_Vert" Stretch="Fill">
    <DrawingBrush.Drawing >
        <DrawingGroup>
            <GeometryDrawing Geometry="M114.000,293.847C114.000,280.324,114.045,269.362,114.100,269.362L391.900,269.362C391.955,269.362,392.000,280.324,392.000,293.847L392.000,485.878C392.000,499.400,391.955,510.362,391.900,510.362L114.100,510.362C114.045,510.362,114.000,499.400,114.000,485.878z">
                <GeometryDrawing.Brush>
                    <LinearGradientBrush StartPoint="114,389.862" EndPoint="392,389.862" MappingMode="Absolute" SpreadMethod="Pad">
                        <GradientStop Color="Black" Offset="0" />
                        <GradientStop Color="#FFDADADA" Offset="0.082" />
                        <GradientStop Color="#FF282828" Offset="0.854" />
                        <GradientStop Color="White" Offset="0.949" />
                        <GradientStop Color="Black" Offset="1" />
                    </LinearGradientBrush>
                </GeometryDrawing.Brush>
            </GeometryDrawing>
        </DrawingGroup>
    </DrawingBrush.Drawing>
    <DrawingBrush.RelativeTransform>
        <RotateTransform CenterX=".5" CenterY=".5" Angle="90"/>
    </DrawingBrush.RelativeTransform>
</DrawingBrush>

可以使用与UniformGrid内联的后台属性。 请尝试以下代码:

<UniformGrid Background="{StaticResource SteelBrush_Vert}"
             Rows="1" 
             Columns="1" 
             Height="75" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Grid.Row="2"/>

你能在我的资源目录中发布你是如何定义SteelBrush_Vert StaticResource?的吗?或者在我的窗口中?在这种情况下,定义它的位置并不重要。我认为问题在于SteelBrush_Vert资源。只需在问题中添加“钢刷垂直”的定义。你能看到我在这里做错了什么吗?现在这太容易了。抱歉这么愚蠢。非常感谢。纵观全局,我们有时会忽略一些简单的问题: