开发者

WPF Background Two Tone

开发者 https://www.devze.com 2023-03-16 12:56 出处:网络
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 exac

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="#AC开发者_运维问答C6E0" 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.

Many Thanks

Paul


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>


You need to add extra GradientStops:

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消