WPF 背景两种色调 [英] WPF Background Two Tone

查看:34
本文介绍了WPF 背景两种色调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一些如此简单的事情,但却一事无成.我一直在网上搜索,试图找到一个清晰的例子或一点点信息,但我找到的每篇文章都展示了完全相同的简单例子.

I'm trying to do something so simple but cannot get anywhere with it. I've been trawling the net trying to find a clear example or tit bit of information but every article I find is showing the exact same simple example.

我想要做的就是有一个列表框项目的背景,它是两种色调,但它们之间没有渐变混合.到目前为止,我有:

All I want to do is have a background to a list box item that is two tone but without a gradial blend between them. So far I have:

<Setter Property="Background" >
    <Setter.Value>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <GradientStop Color="#ACC6E0" Offset="0"/>
            <GradientStop Color="#DCE7F5" Offset="1"/>
        </LinearGradientBrush>
    </Setter.Value>
</Setter>

我尝试了很多不同的东西,但我最终得到的只是渐变的变体,而不是两个音调相等的分割.

I've tried plenty of different things but all I end up with is a variant of a gradual gradient not a two tone equal split.

非常感谢

保罗

推荐答案

只需在相同的偏移量处添加两个停靠点:

Just add two stops at the same offset:

    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#ACC6E0" Offset="0"/>
        <GradientStop Color="#ACC6E0" Offset="0.5"/>
        <GradientStop Color="#DCE7F5" Offset="0.5"/>
        <GradientStop Color="#DCE7F5" Offset="1"/>
    </LinearGradientBrush>

事实上,您可以删除端点:

In fact you can drop the end points:

    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#ACC6E0" Offset="0.5"/>
        <GradientStop Color="#DCE7F5" Offset="0.5"/>
    </LinearGradientBrush>

这篇关于WPF 背景两种色调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆