LinearGradientBrushes中的绝对GradientStops [英] Absolute GradientStops in LinearGradientBrushes
问题描述
如何为LinearGradientBrush
中的GradientStop
指定绝对Offset
?
我有一个以LinearGradientBrush
为背景的GridView
:
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0" Color="White" />
<GradientStop Offset="0.25" Color="White" />
<GradientStop Offset="0.4" Color="WhiteSmoke" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Grid.Background>
当网格为默认大小时,渐变的白色区域大约为60像素单位高.当我调整网格大小时,渐变会拉伸,白色区域会变大.如何使白色区域保持相同的高度,但要拉伸其余的渐变呢?
When the grid is at its default size, the white area of the gradient is about 60 pixel units tall. When I resize the grid, the gradient stretches and the white area gets larger. How can I keep the white area the same height, but stretch the rest of the gradient?
白色区域对应于网格中的一行,因此,如果有一种方法可以使渐变跨越除第一行以外的每一行,那将很好地工作.
The white area corresponds to one row in the grid, so if there's a way to make the gradient span every row but the first one, that would work just fine.
推荐答案
我最终将Grid
拆分为多个Grids
,以获得所需的效果.顶部的网格具有白色背景,中间的网格具有渐变,而底部的网格具有底色.
I ended up splitting the Grid
into multiple Grids
to get the effect I wanted. The top grid had a white background, the middle had the gradient, and the bottom had the end color.
这篇关于LinearGradientBrushes中的绝对GradientStops的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!