Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 以XAML格式旋转DrawingBrush中的渐变_Wpf_Xaml - Fatal编程技术网

Wpf 以XAML格式旋转DrawingBrush中的渐变

Wpf 以XAML格式旋转DrawingBrush中的渐变,wpf,xaml,Wpf,Xaml,我有一个画笔定义,我想旋转梯度。旋转出对象帧时,下面的选项不起作用。如何将其旋转到对象的中心 <DrawingBrush x:Key="SteelBrush_Vert" Stretch="Fill"> <DrawingBrush.Drawing RenderTransformOrigin="0.5, 0.5"> <DrawingGroup> <GeometryDrawing Geometry="M1

我有一个画笔定义,我想旋转梯度。旋转出对象帧时,下面的选项不起作用。如何将其旋转到对象的中心

    <DrawingBrush x:Key="SteelBrush_Vert" Stretch="Fill">
    <DrawingBrush.Drawing RenderTransformOrigin="0.5, 0.5">
        <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 Angle="90"/>
    </DrawingBrush.RelativeTransform>
</DrawingBrush>

我通过猜测和检查找到了答案

   <DrawingBrush x:Key="SteelBrush_Vert" Stretch="Fill">
    <DrawingBrush.Drawing RenderTransformOrigin="0.5, 0.5">
        <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>


我应该将它们设置为什么?我尝试了两个0,但都不起作用几何绘图的意义是什么?几何图形似乎只是一个矩形。你可以很容易地用LinearGradientBrush替换绘图画笔,该画笔具有适当的起点和终点,使其垂直。这是一种几何设计,LinearGradientBrush不会剪切它