找到了。这是画笔的 MappingMode。如果将其设置为 Absolute,它将以实际坐标呈现,而不是控件本身的百分比,这意味着如果您的“全”宽度为 240 单位,则将终点设置为 240。(注意 GradientStop 偏移始终StartPoint 和 EndPoint 之间距离的百分比。)
缺点是每个要渲染的控件的“宽度”需要一个画笔,这意味着如果您有 10 个 200 单位宽的条形图和 6 个 150 单位宽的条形图,您需要两个画笔,每个宽度一个.
这是一个来自 MSDN 的例子......
<!-- The MappingMode property is set to "Absolute" which specifies that the coordinate
system used for the StartPoint and EndPoint properties is not relative to the
Brush output area. Values are interpreted directly in local space. -->
<!-- Create a brush that is absolutely 200 units wide -->
<LinearGradientBrush MappingMode="Absolute"
StartPoint="0,0" EndPoint="200,0">
<GradientStop Color="Yellow" Offset="0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1" />
</LinearGradientBrush>