简体   繁体   English

WPF 背景色

[英]WPF background colors

I would like to create some colors as my WPF background, but I have 2 issues with that:我想创建一些颜色作为我的 WPF 背景,但我有两个问题:

  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.但问题是:当我在 WPF 中创建渐变时,颜色变化有点模糊。

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!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在WPF中绑定ListBox项背景和选择颜色 - Bind ListBox item background & selection colors in WPF 如何更改所有 WPF Windows 背景颜色? - How to change all WPF Windows background colors? 如何在DataGridComboBoxColumn ltems wpf中添加背景色? - How add Background colors in DataGridComboBoxColumn ltems wpf? 如何在WPF中闪烁RichTextBox边框和背景颜色 - How to flash a RichTextBox border and background colors in WPF 从WPF WebBrowser打印背景色 - Printing Background Colors from WPF WebBrowser WPF样式TabControl TabItems自定义前景/背景色 - WPF styling TabControl TabItems custom Foreground/Background colors 如何在 WPF 菜单控件上设置前景色和背景色? - How to set foreground and background colors on a WPF Menu control? 如何在WPF中比较if((sender as Grid).Background == new SolidColorBrush(Colors.Green)) - How to compare if((sender as Grid).Background== new SolidColorBrush(Colors.Green)) in wpf 如何对WPF组合框项目(与可观察的集合绑定)进行分类,并且每个类别必须显示不同的背景色 - How to categories wpf combobox items (bound with observable collection ) & each category must display different background colors 如何在WPF DataGrid GroupStyle的Expander中设置背景和前景色? - How do I set the background and foreground colors in a WPF DataGrid GroupStyle's Expander?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM