-
Notifications
You must be signed in to change notification settings - Fork 701
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
Can't override style of content within templated control #7792
Comments
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). |
Resolve issue with ToggleSwitch override due to microsoft/microsoft-ui-xaml#7792
* Adding new controls * Uno fixes * Added SettingsExpanderSample * Adding sampleref * Bugfixes * CI fix * Fix CI * Adding ExpanderV2 * CI fix * Update Generic.xaml * Add overrides * Uno fixes * CI fix * Update ExampleSettingsControlsTestClass.cs * Simplifing state setting * Revert "Simplifing state setting" This reverts commit a014377. * Quick fix to enable building locally to workaround unoplatform/uno#9297 * Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]> * Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]> * Tweaks * Renamed ButtonIcon to ActionIcon * Make SettingsExpander Content a ContentProperty * File rename * Making the StyleSelector work * Add github.com/rudyhuyn/XamlPlus Attached Style Helper Resolve issue with ToggleSwitch override due to microsoft/microsoft-ui-xaml#7792 * Add binding to Expander option toggle Note: should be TwoWay bound but issue on Uno, added note here for now: #207 (comment) * Removing HeaderedContentControl from the template * XAML styling * Removed HeaderedContentControl out of the SettingsCard template * Adding WrapThreshold * Fix failing test in SettingsCard tests * Tweaked SettingsCard sample * XAML styling * Remove SettingsExpanderItem and use SettingsCard directly Allows for better interop to just cut/paste SettingsCards in/out of Expanders 🙂 * UI tweaks to samples and SettingsCard to render the correct height * Adding VSM only * Temp: Comment out column trigger which was causing control to grow after state change and cause infinite layout cycle i.e. when the break point was reached (e.g. control size 560), VSM was changing the layout and now control size would be larger again (e.g. 605), which would then turn off trigger and re-layout back to old size which would now be smaller again, etc... We need to ensure the transition between the Right and Vertical states doesn't increase the width of the control. * Remove redundant minwidth * Clean up code, comments * Code cleanup SettingsCard * Settings ToolkitSampleRenderer alignment to Stretch * Bumping version number * Removing HeaderedContentControl * Removing remaining reference * Add triggers * Update Generic.xaml * Update Generic.xaml * Use ThemeResource instead of StaticResource Co-authored-by: michael-hawker <[email protected]> Co-authored-by: Rudy Huyn <[email protected]>
Bumping, based on #8638 |
* Adding new controls * Uno fixes * Added SettingsExpanderSample * Adding sampleref * Bugfixes * CI fix * Fix CI * Adding ExpanderV2 * CI fix * Update Generic.xaml * Add overrides * Uno fixes * CI fix * Update ExampleSettingsControlsTestClass.cs * Simplifing state setting * Revert "Simplifing state setting" This reverts commit a014377. * Quick fix to enable building locally to workaround unoplatform/uno#9297 * Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]> * Update labs/SettingsControls/samples/SettingsControls.Samples/SettingsExpanderSample.xaml Co-authored-by: Michael Hawker MSFT (XAML Llama) <[email protected]> * Tweaks * Renamed ButtonIcon to ActionIcon * Make SettingsExpander Content a ContentProperty * File rename * Making the StyleSelector work * Add github.com/rudyhuyn/XamlPlus Attached Style Helper Resolve issue with ToggleSwitch override due to microsoft/microsoft-ui-xaml#7792 * Add binding to Expander option toggle Note: should be TwoWay bound but issue on Uno, added note here for now: CommunityToolkit#207 (comment) * Removing HeaderedContentControl from the template * XAML styling * Removed HeaderedContentControl out of the SettingsCard template * Adding WrapThreshold * Fix failing test in SettingsCard tests * Tweaked SettingsCard sample * XAML styling * Remove SettingsExpanderItem and use SettingsCard directly Allows for better interop to just cut/paste SettingsCards in/out of Expanders 🙂 * UI tweaks to samples and SettingsCard to render the correct height * Adding VSM only * Temp: Comment out column trigger which was causing control to grow after state change and cause infinite layout cycle i.e. when the break point was reached (e.g. control size 560), VSM was changing the layout and now control size would be larger again (e.g. 605), which would then turn off trigger and re-layout back to old size which would now be smaller again, etc... We need to ensure the transition between the Right and Vertical states doesn't increase the width of the control. * Remove redundant minwidth * Clean up code, comments * Code cleanup SettingsCard * Settings ToolkitSampleRenderer alignment to Stretch * Bumping version number * Removing HeaderedContentControl * Removing remaining reference * Add triggers * Update Generic.xaml * Update Generic.xaml * Use ThemeResource instead of StaticResource Co-authored-by: michael-hawker <[email protected]> Co-authored-by: Rudy Huyn <[email protected]>
Describe the bug
We're working on the new
SettingsExpander
control in Windows Community Toolkit Labs: CommunityToolkit/Labs-Windows#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:
MinWidth
to 154, which is way larger than its default width #3652The text was updated successfully, but these errors were encountered: