WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

Samples use custom theme resources

Open michael-hawker opened this issue 2 years ago • 3 comments

Describe the bug

Some of our samples (like ListDetailsView) use custom theme resources {ThemeResource Brush-Blue-01} which cause problems if copied blindly. Any resources defined or used should be part of the sample XAML or we should only use system level resources that are part of OS/WinUI 2.x.

Steps to Reproduce

  • [x] Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)

Steps to reproduce the behavior:

  1. Copy ListDetailsView sample XAML into a new app...
  2. Run, get an exception in MeasureOverride because theme resource is missing

Expected behavior

Easy to copy example and make work in an app.

Environment

NuGet Package(s):

Package Version(s):

Windows 10 Build Number:

  • [ ] Fall Creators Update (16299)
  • [ ] April 2018 Update (17134)
  • [ ] October 2018 Update (17763)
  • [ ] May 2019 Update (18362)
  • [ ] May 2020 Update (19041)
  • [ ] Insider Build ({build_number})

App min and target version:

  • [ ] Fall Creators Update (16299)
  • [ ] April 2018 Update (17134)
  • [ ] October 2018 Update (17763)
  • [ ] May 2019 Update (18362)
  • [ ] May 2020 Update (19041)
  • [ ] Insider Build ({build_number})

Device form factor:

  • [ ] Desktop
  • [ ] Xbox
  • [ ] Surface Hub
  • [ ] IoT

Visual Studio version:

  • [ ] 2017 (15.{minor_version})
  • [ ] 2019 (16.{minor_version})
  • [ ] 2022 (17.{minor_version})

Additional context

This is something probably for us to keep in mind as we re-work samples in the future.

michael-hawker avatar Oct 12 '21 16:10 michael-hawker

Hello michael-hawker, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost avatar Oct 12 '21 16:10 ghost

@michael-hawker What do you think is a good solution to this? Copy each brush definition into the sample, hardcoding a neutral color that works under both themes, or trying to switch to some platform-defined brush?

Arlodotexe avatar Dec 09 '21 21:12 Arlodotexe

@Arlodotexe I think sticking as much to possible to system defined brushes would be great as then even copying a snippet of a sample would work. Worst-case if we need a custom resource, we should probably copy them into each sample as needed from whatever design structure/guidance we have setup, if it's a common thing/color.

We'll need a list of these little details for things to keep track of for new samples in the Labs repo too. 🙂

michael-hawker avatar Jan 25 '22 00:01 michael-hawker