Skip to content

Indeterminate progress bar used as BitmapCacheBrush target do not animate #8960

@mslukebo

Description

@mslukebo

Description

When using a BitmapCacheBrush whose Target is a ProgressBar with Indeterminate="True", the rendered control does not animate.

Reproduction Steps

Create a new WPF project that targets either .NET 7 (net7.0-windows) or .NET 8 (net8.0-windows).

Add the following code to MainWindow.xaml:

<Window x:Class="BlankWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:BlankWpf"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.Resources>
        <ProgressBar x:Key="CachedProgressBar" Width="200" Height="10" IsIndeterminate="True" >
            <ProgressBar.CacheMode>
                <BitmapCache SnapsToDevicePixels="True" />
            </ProgressBar.CacheMode>
        </ProgressBar>

        <BitmapCacheBrush x:Key="CachedProgressBarBrush" Target="{StaticResource CachedProgressBar}" />
    </Window.Resources>

    <Grid>
        <Rectangle Fill="{StaticResource CachedProgressBarBrush}" Width="200" Height="10" />
    </Grid>
</Window>

Run the application.

Expected behavior

An animated, indeterminate progress bar should be rendered. This is the behavior on .NET 6.

progress

Actual behavior

A static, completely filled progress bar is rendered:

image

Regression?

This is a regression; it used to work in .NET 6.

Known Workarounds

Instead of using a BitmapCacheBrush, you can use a VisualBrush and assign its Visual property to the progress bar (instead of the BitmapCacheBrush.Target property). This fixes the UI, but obviously is less ideal than using a BitmapCacheBrush.

Impact

My application uses many progress bars that we synchronize and reduce their overhead with by using the bitmap cache. This bug breaks all of those bars.

Configuration

No response

Other information

No response

Metadata

Metadata

Labels

🚧 work in progressBugProduct bug (most likely)InvestigateRequires further investigation by the WPF team.regressionstatus: This issue is a regression from a previous build or release

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions