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>

效果:

相关推荐
白露与泡影6 小时前
基于Mongodb的分布式文件存储实现
分布式·mongodb·wpf
Tummer83631 天前
C#+WPF+prism+materialdesign创建工具主界面框架
开发语言·c#·wpf
炯哈哈1 天前
【上位机——WPF】App.xml和Application类简介
xml·开发语言·c#·wpf·上位机
CoderIsArt1 天前
WPF的UI元素类型详解
ui·wpf
zxfgdjfjfjflfllf1 天前
Mapreduce初使用
大数据·wpf·mapreduce
炯哈哈2 天前
【上位机——WPF】Window标签常用属性
开发语言·c#·wpf·上位机
绿龙术士3 天前
构建现代化WPF应用:数据驱动开发与高级特性解析
c#·wpf
wangnaisheng5 天前
【WPF】Opacity 属性的使用
wpf
姬激薄5 天前
配置Hadoop集群-集群配置
wpf
python算法(魔法师版)5 天前
.NET 在鸿蒙系统上的适配现状
华为od·华为·华为云·.net·wpf·harmonyos