Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Background Two Tone

Tags:

wpf

xaml

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.

Many Thanks

Paul

like image 384
Paulie Waulie Avatar asked Dec 12 '22 11:12

Paulie Waulie


2 Answers

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>
like image 77
H.B. Avatar answered Jan 03 '23 10:01

H.B.


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>
like image 44
Phil Devaney Avatar answered Jan 03 '23 10:01

Phil Devaney