簡體   English   中英

WPF線條顏色比其筆刷顏色更深

[英]WPF line color is darker than its brush color

在我的WPF應用程序中,我使用一行和一些矩形來制作圖表。 但是,當我將線條設置為白色時,它顯示為灰色。 我將線條顏色更改為與其旁邊的紅色矩形相同,很明顯線條較暗。 這是我對直線和矩形的實例化:

<Line Grid.Row="2" X1="0" Y1="0" X2="0" Y2="105" 
                  StrokeThickness="1" Stroke="{StaticResource FgRedBrush}" SnapsToDevicePixels="True" UseLayoutRounding="True"
                  Margin="10 0 0 10" VerticalAlignment="Bottom" StrokeEndLineCap="Flat" />
            <Rectangle Grid.Row="2" Width="100" Height="30"
                       Fill="{StaticResource FgGreenBrush}"
                       Margin="11 0 0 25" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
            <Rectangle Grid.Row="2" Width="170" Height="30" 
                       Fill="{StaticResource FgRedBrush}"
                       Margin="11 0 0 70" VerticalAlignment="Bottom" HorizontalAlignment="Left" />

另外,這是組件的圖片: 在此輸入圖像描述

沒關系硬編碼,我只是感覺布局。

具有畫筆資源定義的文件:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:Financial_Manager.Colors">

<Color x:Key="ForegroundLight">#D7F6F6</Color>
<Color x:Key="ForegroundDark">#898989</Color>
<Color x:Key="ForegroundPurple">#D228FF</Color>
<Color x:Key="ForegroundBlue">#4DC6D2</Color>
<Color x:Key="ForegroundOrange">#F99D10</Color>
<Color x:Key="ForegroundGreen">#37AE53</Color>
<Color x:Key="ForegroundRed">#CE260B</Color>
<Color x:Key="ForegroundYellow">#CCFF00</Color>

<SolidColorBrush x:Key="FgLightBrush" Color="{StaticResource ForegroundLight}" />
<SolidColorBrush x:Key="FgDarkBrush" Color="{StaticResource ForegroundDark}" />
<SolidColorBrush x:Key="FgPurpleBrush" Color="{StaticResource ForegroundPurple}" />
<SolidColorBrush x:Key="FgBlueBrush" Color="{StaticResource ForegroundBlue}" />
<SolidColorBrush x:Key="FgOrangeBrush" Color="{StaticResource ForegroundOrange}" />
<SolidColorBrush x:Key="FgGreenBrush" Color="{StaticResource ForegroundGreen}" />
<SolidColorBrush x:Key="FgRedBrush" Color="{StaticResource ForegroundRed}" />
<SolidColorBrush x:Key="FgYellowBrush" Color="{StaticResource ForegroundYellow}" />

<Color x:Key="BackgroundLight">#0D0A1C</Color>
<Color x:Key="BackgroundDark">#080610</Color>

<SolidColorBrush x:Key="BgLightBrush" Color="{StaticResource BackgroundLight}" />
<SolidColorBrush x:Key="BgDarkBrush" Color="{StaticResource BackgroundDark}" />

在評論中克萊門斯的幫助下,我發現當線條厚度接近2時,顏色值接近真實顏色。 雖然我仍然不知道為什么並且願意學習,但臨時修復是將厚度設置為1.99以使顏色看起來相同。 雖然厚度基本上為2,但它仍然具有與1相同的視覺外觀。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM