WPF—画刷(使用画刷实现背景颜色渐变效果)

WPF---画刷(使用画刷实现背景颜色渐变效果)

在WPF中我们可以使用画刷来对我们的页面做出各种炫丽的效果,列如渐变,渲染等,

下列就为大家分享2个渐变效果示例:

实例1(由内到外)

cs 复制代码
<Grid>
    <!--背景颜色渐变 画刷-->
    <Grid.Background>
        <!--RadialGradientBrush由内到外-->
        <RadialGradientBrush>
            <GradientStop Color="#ccd5f0"
                          Offset="0"></GradientStop>
            <GradientStop Color="#5d6b99"
                          Offset="0.5"></GradientStop>
            <GradientStop Color="#40568d"
                          Offset="1"></GradientStop>
        </RadialGradientBrush>
    </Grid.Background>
</Grid>

效果:

实例2(左上角到右下角)

cs 复制代码
<Grid>
    <!--背景颜色渐变 画刷-->
    <Grid.Background>
        <!--LinearGradientBrush 左上角到右下角渐变-->
        <LinearGradientBrush>
            <GradientStop Color="#ccd5f0"
                          Offset="0"></GradientStop>
            <GradientStop Color="#5d6b99"
                          Offset="0.5"></GradientStop>
            <GradientStop Color="#40568d"
                          Offset="1"></GradientStop>
        </LinearGradientBrush>
    </Grid.Background>
</Grid>

效果:

相关推荐
dalong1014 小时前
WPF:3D正四面体旋转改错
3d·wpf
dalong101 天前
WPF:3D正四面体自动旋转
3d·wpf
He BianGu1 天前
【WPF-Control】二次开发总览
wpf
绿浪19842 天前
WPF 后台刷新界面总结
wpf
绿浪19842 天前
WPF UI标准流水线
ui·wpf
心平气和量大福大3 天前
C#-WPF-控件-LiveChart图表-线性2(LineSeries)-数据绑定
开发语言·c#·wpf
绿浪19843 天前
WPF 防重入,时序错乱详解
wpf
whn19774 天前
oracle的节点2无法启动asm实例 提示PMON terminating the instance due to error 481
数据库·oracle·wpf
完美火龙篇 四月的友4 天前
WPF 笔迹延迟优化从硬件到软件的全链路分析
wpf
dalong104 天前
WPF:3D立方体
3d·wpf