views:

112

answers:

2

Following a problem in WPF 4 where the default ProgressBar template has an off-white highlight applied causing it to dull the foreground colour, I decided to extract the template and manually edit the values to white.

After doing this, I put the template as a style in App.xaml for global use and the Visual Studio designer began to use it right away.

However, when I run my app, the default style is still being applied: Top - Application, Bottom - Designer

I then tried setting the style specifically using a key, then even having it as an inline style and finally as a inline template without a wrapping style for the specific progress bar and it is still ignored.

What's going wrong?

Current Code for progress bar:

 <ProgressBar Grid.Column="1"
                 Grid.Row="2"
                 Height="15"
                 Width="355"
                 Margin="0,0,0,7"
                 IsIndeterminate="{Binding ProgressState, FallbackValue=False}"
                 Visibility="{Binding ProgressVisibility, FallbackValue=Collapsed}"
                 Value="{Binding ProgressValue, Mode=OneWay, FallbackValue=100}"
                 Foreground="{Binding ProgressColor,FallbackValue=Red}">
        <ProgressBar.Template>
            <ControlTemplate>
                <Grid Name="TemplateRoot"
                      SnapsToDevicePixels="True">
                    <Rectangle RadiusX="2"
                               RadiusY="2"
                               Fill="{TemplateBinding Panel.Background}" />
                    ...
A: 

Just to be sure. You are binding internal Rectangle to the Background property, while it's not set in the ProgressBar definition (only Foreground is there). Is that correct?

Anvaka
That's the background of the progressbar as defined in the original template.
Nidonocu
+1  A: 

I've found the error I believe. It seems that even though the template was extracted from the build in version. There was some kind of error with the following trigger in the template:

<Trigger Property="ProgressBar.IsIndeterminate">
    <Setter Property="Panel.Background"
            TargetName="Animation">
        <Setter.Value>
            <SolidColorBrush>#80B5FFA9</SolidColorBrush>
        </Setter.Value>
    </Setter>
    <Trigger.Value>
        <s:Boolean>False</s:Boolean>
    </Trigger.Value>
</Trigger>

As soon as I removed this trigger (which had no visible impact on the visuals) the template began to work.

Nidonocu