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>

效果:

相关推荐
IOFsmLtzR13 小时前
Flink Agents 源码解读 --- (5) --- ActionExecutionOperator
microsoft·flink·wpf
廋到被风吹走2 天前
【AI】Codex 复杂任务拆解:从“一气呵成“到“步步为营“
人工智能·wpf
希望永不加班2 天前
SpringBoot 整合 Redis 缓存
spring boot·redis·后端·缓存·wpf
_MyFavorite_2 天前
JAVA重点基础、进阶知识及易错点总结(29)JDK8 时间 API 进阶
java·开发语言·wpf
武藤一雄3 天前
深入拆解.NET内存管理:从GC机制到高性能内存优化
windows·microsoft·c#·.net·wpf·.netcore·内存管理
武藤一雄5 天前
WPF/C# 应对消息洪峰与数据抖动的 8 种“抗压”策略
windows·微软·c#·wpf·.netcore·防抖·鲁棒性
武藤一雄6 天前
WPF深度解析Behavior
windows·c#·.net·wpf·.netcore
Maybe_ch6 天前
WPF的STA线程模型、APM与TAP:从线程约束到现代异步
c#·.net·wpf
FuckPatience6 天前
WPF 实现windows文件压缩文件解压过程动画
wpf
会飞的大可6 天前
Spring Cloud Alibaba全景:Nacos、Sentinel、Seata整合实战
sentinel·wpf