简体   繁体   中英

WPF background colors

I would like to create some colors as my WPF background, but I have 2 issues with that:

  1. When I resize windows, coloring being resized with it. I would like to have it static.
  2. My colors are specific: They are not toned, they should look something like this:

颜色

But the problem is: When I create a gradient in WPF, color changes are kind of blurred.

I have tried to do it that way :

<Window.Background>
    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="#70116B" Offset="0" />
        <GradientStop Color="#70116B" Offset="0.4" />
        <GradientStop Color="#BBD909" Offset="0.4" />
        <GradientStop Color="#BBD909" Offset="0.5" />
        <GradientStop Color="#0093DD" Offset="0.5" />
        <GradientStop Color="#0093DD" Offset="0.52" />
        <GradientStop Color="White" Offset="0.52" />
        <GradientStop Color="White" Offset="1" />
    </LinearGradientBrush>
</Window.Background>

But like I said: it's not what I want

What you want to achieve isn't a gradient. But i would suggest you to use something like below:

  <Grid>  
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="0.4*"/>
      <ColumnDefinition Width="0.1*"/>
      <ColumnDefinition Width="0.02*"/>
      <ColumnDefinition Width="0.48*"/>
    </Grid.ColumnDefinitions>
    <Grid Grid.Column="0" Background="#70116B"/>
    <Grid Grid.Column="1" Background="#BBD909"/>
    <Grid Grid.Column="2" Background="#0093DD"/>
    <Grid Grid.Column="3" Background="#FFFFFF"/>
  </Grid>

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM