microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.28k stars 674 forks source link

ControlCornerRadius resource doesn't respect app-level scope #1486

Closed kikisaints closed 1 year ago

kikisaints commented 4 years ago

Describe the bug

When I target the newest release of WinUI (2.2) or even the current pre-release (2.3) and I attempt to set the ControlCornerRadius resource at the app-level. Either by directly declaring it in App.Resources or by merging in a ResourceDictionary at the app-level - the ControlCornerRadius resource fails to apply to the controls on my page.

However, if I merge that same dictionary in at the page-level, or declare the resource at the page-level it will apply to my controls correctly.

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Create a 2.2 or 2.3 WinUI app
  2. Override the ControlCornerRadius resource at the App.xaml level
  3. Add some controls to the MainPage.xaml that are bound to the ControlCornerRadius resources
  4. Deploy the app and notice that no corners are getting rounded to the values you specified

Expected behavior

I would expect at both the page-level and the app-level that the ControlCornerRadius would effect all controls under the respective scope.

Version Info

NuGet package version: Microsoft.UI.Xaml 2.3.190917002

Windows 10 version Saw the problem?
Insider Build (18843) Yes
May 2019 Update (18362) Yes
Device form factor Saw the problem?
Desktop Yes
kaiguo commented 4 years ago

Looks like app level resource overriding is broken. @jevansaks is this a known bug? I tried compact resources and they didn't seem to work either.

jevansaks commented 4 years ago

I don't know off the top of my head. I know that you, @licanhua and @stephenlpeters had done various investigations here. Is there a summary of those investigations? My guess is that at the end of the day there's a framework bug (or more than one). Maybe you can sit with Bartek and figure out the problem(s) and next steps?

kaiguo commented 4 years ago

Yeah there was a framework bug for popup based control resource overrides (which makes OverlayCornerRadius not work). But this one, looks like the override doesn't work at all in app level, which feels like a bigger problem. I'll ask Bartek...

Felix-Dev commented 4 years ago

Any updates on this one?

The bug also applies to the several control-specific border thickness resources (such as TextControlBorderThemeThickness).

marcelwgn commented 4 years ago

I've tried to reproduce the issue, but using the XCG as test project, and adding

<CornerRadius x:Key="ControlCornerRadius">0,0,0,0</CornerRadius>

to the ResourceDictionary of App.xaml, components that use this resource (e.g. buttons) seem to render correctly and without rounded corners.

Felix-Dev commented 4 years ago

@chingucoding Tested it on my local machine with the latest release and preview-release versions of WinUI (no WinUI 3.0) and SDK 18362 and the resource override is still not applied when located in App.xaml. Are you already running on 19H2 and if yes, could the fix for this issue be at the OS level then? 🤔

marcelwgn commented 4 years ago

@Felix-Dev I am running the Insider version 19018.

Maybe this is really a bug that lays inside the OS, though I am very confused why that would be something inside the OS.

ranjeshj commented 4 years ago

If you are using the same WinUI 2.x build and it works on a newer OS version but not an older one, it is possible that the bug is in the framework (wux.dll which currently ships with the OS). wux.dll is being moved out of the OS into WinUI 3 currently.

Felix-Dev commented 4 years ago

@ranjeshj Any chance the fix, if one does exist for newer windows insider builds, will be backported to current windows versions? Or will we have to wait for WinUI 3.0?

ranjeshj commented 4 years ago

I would like to understand better if this is really a framework bug. @kaiguo - were you able to identify/root case this issue to a framework bug that was fixed ? Is there a workaround ? @Felix-Dev, if this is a framework bug, it will be fixed in WinUI 3 and you will likely have to workaround in the mean time unfortunately.

kaiguo commented 4 years ago

Yeah I did some investigations earlier, I think it's more of a "limitation" rather than a bug...

My understand is this has something to do with the way we read resources, when ControlCornerRadius (or any app level overloading resource) is getting loaded, Application.Resources hasn't been loaded yet (value is still null) , we don't have look ahead ability so there's nothing to override. @ranjeshj I forwarded you an email with some more info.

But yeah, this is definitely a framework issue and we'd have to wait for WinUI 3. The workaround will be overriding the resource in page or control level instead of app level.

ranjeshj commented 4 years ago

Linking internal bug link - https://microsoft.visualstudio.com/OS/_workitems/edit/20908500 FYI @chrisglein in case he wants to add more details to this conversation.

licanhua commented 4 years ago

This is an known restriction from platform(#430), and it's impossible to fix it in WinUI 2.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.