unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.79k stars 708 forks source link

Resources altered in one window are affecting other windows #15221

Open ramezgerges opened 8 months ago

ramezgerges commented 8 months ago

Current behavior

In our SamplesApp, the thumb of the ScrollBar in one window is affected when the other window's Thumb changes color. https://github.com/unoplatform/uno/assets/66218781/c3232a34-e465-4563-af2e-750ec29c6f42

I've investigated a bit, and the problem seems to be mainly that the global ResourceDictionaries are shared between windows. ScrollBar's animations change the Background.Color of the Thumb. Since Background is set to {ThemeResource ScrollBarPanningThumbBackground}, altering its Color will affect all elements that are using ScrollBarPanningThumbBackground. Note however that in WinUI, altering the Color of a brush in a ResourceDictionary does indeed affect other elements in the same Window, so our behaviour is accurate within the same window. Theoretically, this would mean that we should be creating separate instances of the resource dictionaries per window.

Expected behavior

I couldn't test on WinUI, but I'm confident that this is not the expected behaviour

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Youssef1313 commented 8 months ago

This might be the responsibility of https://github.com/unoplatform/uno/blob/44d853f1eecc28439e4a020ab5f955992acb52ea/src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs#L112

Clone implementation:

https://github.com/unoplatform/uno/blob/44d853f1eecc28439e4a020ab5f955992acb52ea/src/Uno.UI/UI/Xaml/Media/SolidColorBrush.cs#L102

mcNets commented 2 weeks ago

@Youssef1313 can this be closed? Seems implemented already.

Youssef1313 commented 2 weeks ago

The issue is still reproducible, but for some reason only reproducible in old UWP styles