Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to customize Expander control by overriding resource keys #6688

Closed
1 of 2 tasks
AndradeL opened this issue Feb 8, 2022 · 4 comments
Closed
1 of 2 tasks

Unable to customize Expander control by overriding resource keys #6688

AndradeL opened this issue Feb 8, 2022 · 4 comments
Labels
area-Expander area-Resources help wanted Issue ideal for external contributors no-issue-activity team-Controls Issue for the Controls team

Comments

@AndradeL
Copy link

AndradeL commented Feb 8, 2022

Describe the bug

The Expander class API guide recommends modifying specific resource keys for customizing the look of the Expander:
https://docs.microsoft.com/en-us/windows/winui/api/microsoft.ui.xaml.controls.expander?view=winui-2.6#remarks

When trying to do so by setting: <x:Double x:Key="ExpanderChevronGlyphSize">20</x:Double> for example, nothing changes.
Some of the resources actually works, like setting

I've tried setting this properties both on the App scope and in a Page scope but none of them work.

Steps to reproduce the bug

  1. Instantiate a Expander in a Page
  2. Add <x:Double x:Key="ExpanderChevronGlyphSize">20</x:Double> to Page.Resources to see if there is any change in the Expander UI.

Expected behavior

The UI elements of the Expander that reference the resource keys should change properly, as specified in its API reference.

Screenshots

Default chevron style is the same as when trying to customize:
image

NuGet package version

Microsoft.UI.Xaml 2.6.2

Windows app type

  • UWP
  • Win32

Device form factor

No response

Windows version

May 2021 Update (19043)

Additional context

Processor Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz 1.99 GHz
Installed RAM 24.0 GB (23.9 GB usable)
System type 64-bit operating system, x64-based processor

Edition Windows 10 Enterprise
Version 21H2
OS build 19044.1466
Experience Windows Feature Experience Pack 120.2212.3920.0

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Feb 8, 2022
@StephenLPeters
Copy link
Contributor

ExpanderChevronGlyphSize is referenced via static resource

Width="{StaticResource ExpanderChevronGlyphSize}"
, which unfortunately means that the UI Tree resource dictionary wont be searched (because this style is defined in your app.xaml) Additionally the resource is defined in the base dictionary of XCR
<x:Double x:Key="ExpanderChevronGlyphSize">12</x:Double>
, which means that there isn't a place in the XCR that this resource can be overrided and found by the lookup.
We should change this resource to be referenced via theme resource so that it can be overriden at the page level.

@AndradeL are there other resources with this control that you want to override and can't?

@StephenLPeters StephenLPeters added area-Expander area-Resources help wanted Issue ideal for external contributors team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Mar 4, 2022
@AndradeL
Copy link
Author

AndradeL commented Mar 5, 2022

I've already found a way to fix this problem on my code by customizing a copy of the ControlTemplate, however I believe it's important to have it consistent with documentation specified on https://docs.microsoft.com/en-us/windows/winui/api/microsoft.ui.xaml.controls.expander?view=winui-2.6#remarks

@bogdan-patraucean
Copy link

bogdan-patraucean commented Mar 8, 2022

@AndradeL can you please give me a sample? I try to remove the padding but with no succes..
@StephenLPeters I tried to override ExpanderHeaderPadding and it doesn't work. I think it would be nice to let us override all resources that were defined as static.

@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Expander area-Resources help wanted Issue ideal for external contributors no-issue-activity team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants