ProgressRing keeps its old colour when the brush assigned to Foreground changes colour
Current behavior
A ProgressRing hands its colours to its animated visual only when the Foreground or Background dependency property itself changes, plus once when its template is applied. If the property keeps pointing at the same SolidColorBrush and that brush's Color changes, the ring goes on painting the old colour indefinitely.
This shows up in themed apps: a brush resource whose Color is re-evaluated at runtime is mutated in place rather than replaced, so every other control repaints and the ring does not.
The animation is not involved — a determinate ring that has never animated behaves the same way.
Expected behavior
The ring repaints in the brush's new colour, like every other control drawn with the same brush.
How to reproduce
No theming needed:
var brush = new SolidColorBrush(Colors.Red);
var ring = new ProgressRing
{
Foreground = brush,
IsActive = true,
IsIndeterminate = false,
Value = 70,
Width = 80,
Height = 80,
};
// put it in the tree and let it render -> the ring paints red
brush.Color = Colors.Lime;
// -> the ring still paints redMeasured by rasterising the ring with RenderTargetBitmap and reading the pixels back:
| step | rendered |
|---|---|
| baseline, brush is red | red |
brush.Color = Colors.Lime |
still red |
IsIndeterminate toggled true then false |
lime |
Foreground set to null and back to the same brush |
lime |
| the ring replaced by a new instance | lime |
Workaround
Force the property to change. Toggling IsIndeterminate and putting it straight back makes the ring build its animated visual again and read the brush as it then is.
Environment
Uno Platform 6.8.0-dev.112, net9.0-desktop (Skia), .NET 9. Not checked on other targets.
Notes
ProgressRing registers property-changed callbacks on Foreground and Background and pushes the colour into the animated visual from there, plus once in OnApplyTemplate. Nothing observes the brush's own changes, so a brush mutated in place never reaches the ring.
Source: unoplatform/uno