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>

效果:

相关推荐
小北方城市网10 小时前
Redis 分布式锁高可用实现:从原理到生产级落地
java·前端·javascript·spring boot·redis·分布式·wpf
流水线上的指令侠20 小时前
补充说明——针对《C#:从 0 到 1 创建基于 NUnit + FlaUI 的 WPF UI 自动化测试项目》
功能测试·ui·c#·自动化·wpf
流水线上的指令侠20 小时前
C# 实战:从 0 到 1 搭建基于 NUnit + FlaUI 的 WPF UI 自动化测试项目
功能测试·ui·c#·自动化·wpf·visual studio
贾修行1 天前
.NET 全栈开发学习路线:从入门到分布式
c#·.net·wpf·asp.net core·web api·winforms·services
晓13131 天前
第四章:Redis实战应用及常见问题(下篇)
java·数据库·缓存·wpf
掘根2 天前
【jsonRpc项目】客户端的Requestor模块,RpcCaller模块
wpf
FuckPatience2 天前
WPF ListBoxItem绑定自己在ListBox中的顺序
wpf
天才奇男子3 天前
LVS原理及部署
linux·运维·云原生·wpf·lvs·linux chrony
予枫的编程笔记3 天前
【Redis实战进阶篇1】Redis 分布式锁:从手写实现到 Redisson 最佳实践
redis·分布式·wpf
小北方城市网4 天前
Spring Cloud Gateway 生产级实践:高可用架构、灰度发布与故障排查
spring boot·redis·分布式·缓存·架构·wpf