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>

效果:

相关推荐
张工在路上13 小时前
WPF 布局基础概述
大数据·hadoop·wpf
迪飞特科技2 天前
分布式事务下 Spring 声明式事务失效的 3 种修复方案
分布式·spring·wpf
2601_962174174 天前
Redis 简介
数据库·redis·wpf
SamChan906 天前
Python+PyMuPDF提取PDF表格并翻译:表格结构检测与双语重建实战
windows·python·ai·pdf·wpf
SamChan906 天前
Python+OpenCV检测PDF翻译后排版偏移:像素级格式一致性验证
python·opencv·ai·pdf·wpf
FuckPatience6 天前
WPF 拿到控件的最初样式,修改获得焦点样式
wpf
主宰者6 天前
【WPF】MainWindow前添加加载窗口,发现加载过程中有白色无内容窗口闪烁一下的解决方案
wpf
Vae_Mars7 天前
WPF中的ControlTemplate(控件模板)
wpf
SamChan907 天前
Python+ReportLab自动生成PDF翻译质量审计报告:从数据到可视化的完整方案
开发语言·python·ai·pdf·wpf
circuitsosk7 天前
多智能体协同在能源数据分析中的实践:分配-执行-校验闭环架构设计
python·数据分析·wpf·能源·并行计算·多智能体系统·agent协作