Skip to content

Updating WinUI properties via resources does not take effect #7820

@mattleibow

Description

@mattleibow

Description

Setting certain properties on Windows does not directly update the control but rather the resources. For example, Button.BorderWidth. As a result, the property makes no visible change until something triggers the OS theme to change.

The reason this happens is that properties are set in the styles using {ThemeResource} which is just a {StaticResource} tied to a theme. This means that it is just a read once thing - unless the theme changes.

There is a workaround and that is to toggle the theme, but a "real fix" is coming in https://dev.azure.com/microsoft/OS/_workitems/edit/39897009/

This fix I believe for the interim will basically trigger theme updates without requiring the toggling of the theme. However, the end result is basically the same, the theme is refreshed for he entire control. This totally can change but for now this will make things work.

Related to:

And related to WASDK:

Version with bug

6.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

All

Did you find any workaround?

There is a workaround and that is to get the native control and toggle the RequestedTheme.

Relevant log output

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions