I have WPF
application with ListView
and ProgressBar
inside.
I define this color as Foreground
to my ProgressBar
:
under Windows 8
i can see this color but under Windows 7
i can see different color:
So my question is is it possible to see my desire color in all OS ?
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 hasn't changed.
At Default, WPF picks system colors(based on OS) if you didn't provide any styles for the controls. If you want to run unique style through out all OS then you have to override styles of the controls and have to merge Styles Xaml to your application For Ex:
<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Red"/>
</Style>
<Button Style="{StaticResource ButtonStyle}" />
It's quite simple, you just need to use your style to modify the Border, PART_Track grid and the rectangle inside (which is the progress portion of the overall control).
Here's an example where I've made the background of the whole thing white, the border black - and the progress part 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 vary between Windows 7 or 8!
So with a white background:
Or with a green background:
<Border BorderBrush="Black" BorderThickness="1" Background="Green" CornerRadius="0" Padding="0">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With