LinearGradientBrushes中的绝对GradientStops [英] Absolute GradientStops in LinearGradientBrushes

查看:95
本文介绍了LinearGradientBrushes中的绝对GradientStops的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆