Open michael-hawker opened 2 years ago
I think what's happening in the first case is that the ToggleSwitch has two parents: the Button (because it's set as Button.Content) and the ContentPresenter (because the binding causes it to also be ContentPresenter.Content). That creates ambiguity when walking up the tree to find an implicit style: which parent to follow? What happens with ContentControls like Button and ListView Item is a preference the templated parent (the Button over the ContentPresenter).
WinUI doesn't have API around this, but this is the same logical tree concept as in WPF (WinUI doesn't have the LogicalTreeHelper like WPF).
Bumping, based on https://github.com/microsoft/microsoft-ui-xaml/discussions/8638
Describe the bug
We're working on the new
SettingsExpander
control in Windows Community Toolkit Labs: https://github.com/CommunityToolkit/Labs-Windows/pull/253As part of this we need to ensure that
ToggleSwitch
controls as part of the content get the proper styling to align to the design guidelines for this pattern:Not this:
We need this to be done implicitly so developers don't have to add extra styling for each common option they add to their app. The style is part of using this contract in the control. We've done this in other places and scenarios, but this specific one is failing and we don't understand the differences in the setup here causing the issue.
Steps to reproduce the bug
Minimal repro (both UWP and WinUI 3):
We also tried not using Template Binding and setting the content property of the inner
ContentPresenter
inOnApplyTemplate
but that didn't work as expected either. (It's also not tied toToggleSwitch
as the content either, could be aButton
just an example for our scenario.)All controls should have red background.
Expected behavior
Style is properly overridden and picked up by the content of the control.
Screenshots
No response
NuGet package version
No response
Windows app type
Device form factor
Desktop
Windows version
Windows 10 (21H2): Build 19044
Additional context
Related other issues:
3652
6688
2913
3939