WPF: why my foreground color looks different in different OS

I have a WPF application with ListView and ProgressBar inside. I define this color as Foreground for my ProgressBar :

enter image description here

under Windows 8 I can see this color, but under Windows 7 I see a different color:

enter image description here

So my question is, can I see the color of my desire in all OSs?

Edit:

This is the style I created:

 <Style x:Key="CustomProgressBar" TargetType="ProgressBar" > <Setter Property="Foreground" Value="#FF15669E"></Setter> </Style> 

And this is my ProgressBar :

 <ProgressBar Name="prog" Maximum="100" Value="{Binding Progress}" Width="{Binding Path=Width, ElementName=ProgressCell}" Background="#FFD3D0D0" Style="{StaticResource CustomProgressBar}"/> 

But the color has not changed.

+5
source share
2 answers

It's pretty simple, you just need to use your style to change the Border grid, PART_Track and the rectangle inside (which is part of the progress of the general control).

Here is an example where I made the background of the whole thing white, a black frame - and part of the progress is blue:

 <Style x:Key="CustomProgressBar" TargetType="ProgressBar" > <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ProgressBar"> <Border BorderBrush="Black" BorderThickness="1" Background="White" CornerRadius="0" Padding="0"> <Grid x:Name="PART_Track"> <Rectangle x:Name="PART_Indicator" HorizontalAlignment="Left" Fill="Blue" /> </Grid> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> 

This should not change between Windows 7 or 8!

So, on a white background: enter image description here

Or with a green background:

 <Border BorderBrush="Black" BorderThickness="1" Background="Green" CornerRadius="0" Padding="0"> 

enter image description here

+1
source

By default, WPF selects system colors (based on the OS) if you have not provided any styles for the controls. If you want to run a unique style across the entire OS, you need to redefine the styles of the controls and combine the Xaml styles into your application For Ex:

  <Style x:Key="ButtonStyle" TargetType="Button"> <Setter Property="Background" Value="Red"/> </Style> <Button Style="{StaticResource ButtonStyle}" /> 
+3
source

All Articles