-
Notifications
You must be signed in to change notification settings - Fork 56
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
🧪 [Experiment] SettingsCard & SettingsExpander #216
Comments
Had a discussion with @niels9001 about some implementation details and how we can share common elements between the layout of both We realized our existing Updated Plans:
|
Seems like we may want the |
Actually.. aren't there 12 potential, and useful, positions? And if so - would it make sense to have IconPosition (Left, Top, Right, Bottom), HorizontalIconAlignment and VerticalIconAlignment properties? |
Good catch @niels9001, your image is what I had in my mind, I just over-simplified it. I'm wondering if I'd really like to avoid having to have a Horizontal/Vertical property as then you need to pair them and as a Dev know when to use which based on the other position, so I feel like it makes it more complex to use, comprehend, and change easily. However, a single property would be hard to describe all 12 positions uniquely... As I don't think Just expanding thoughts for completeness here... Starting from the left side on the bottom and going clock-wise:
It's weird, but not horrible, maybe??? Would we want in this case to use |
Hah! That was what I have implemented and feels comprehensible :). I like adding the Center to Left/Top/Right/Bottom to it - will update! |
To help digest what we need for this. I'm getting RelativePanel vibes from this, which we could borrow ideas from. 2 enums is doable as well, but we can't use Horizontal/Vertical alignment. Thinking If we want a single enum, we're going to need to make order matter - and we'll want to clearly define it. Which one is TopRight, and which is RightTop? Since the naming is so clear on the 2 enums, that gets my vote. |
Great point! I believe we should define a MinWidth property, and add adaptivity - seems that the W11 Settings is doing this as well! I'll add this to the requirements in the discussion (#129) :)! |
We're about to merge a first version of the SettingsExpander and a bunch of improvements to SettingsCard. @dongle-the-gadget this should resolve your layout issue as well! Known issues:
|
Hi, @michael-hawker @niels9001
Thanks for looking into this matter as it's required A11y fix for our app. |
@eloisepeng Great feedback! Can you provide some sample XAML for me to test with? |
Hey Niels, I have an idea to improve the SettingsCard! <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"
MinWidth="{ThemeResource SettingsCardLeftIndention}" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> And <x:Double x:Key="SettingsCardLeftIndention">0</x:Double>
(...)
<Thickness x:Key="SettingsCardIconMargin">2,0,20,0</Thickness>
<Thickness x:Key="SettingsCardHeaderIconMargin">2,0,20,0</Thickness> So, when we add content in the second column, without an icon, we need to manually set <controls:CheckBoxWithDescriptionControl
Margin="56,0,0,0" which is too much work and not logical or pretty code style. I would advice to use a MinWidth that equals the width of an icon, so that the space will always be reserved. After that, there is no more need for the manual and redundant left and right margin inside controls. including ActionIconPresenter<ContentControl x:Name="PART_ActionIconPresenter"
Margin="4,0,-8,0"
(...) Also, I strongly recommend to use Grid.Spacing and StackPanel.Spacing for the margins as shown on https://learn.microsoft.com/windows/apps/design/basics/content-basics. Note that it would be most pretty to make all these spacings symmetrical. P.S. is the best word indention or indentation? |
Thanks for the feedback @Jay-o-Way ! The reason why we introduced the different styles and resources (like the Margins and SettingsCardLeftIndention) is that it provides most flexibility for developers to tweak their cards to their liking (see https://learn.microsoft.com/en-us/windows/apps/design/style/xaml-styles#lightweight-styling) and is inline with how WinUI creates their control styles. Although we want to provide a control that "just works" out of the box, we should also support this level of customization. For instance, moving to Grid.Spacing/StackPanel.Spacing might have unintended behavior as it would override everything within the Grid/StackPanel - and would not allow you to just tweak e.g. the HeaderIconMargin? XAML: <labs:SettingsCard Header="SettingsCard" Description="Without an icon">
<Button Content="Content"/>
</labs:SettingsCard>
<labs:SettingsCard Header="SettingsCard" Description="With an icon" HeaderIcon="{ui:FontIcon Glyph=}">
<Button Content="Content"/>
</labs:SettingsCard>
<labs:SettingsCard Header="SettingsCard" Description="Without an icon but with left indention">
<Button Content="Content"/>
<labs:SettingsCard.Resources>
<x:Double x:Key="SettingsCardLeftIndention">120</x:Double>
</labs:SettingsCard.Resources>
</labs:SettingsCard>
<labs:SettingsExpander Header="SettingsExpander" Description="With an icon" HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=}">
<Button Content="Content"/>
<labs:SettingsExpander.Items>
<labs:SettingsCard Header="SettingsCard" Description="With an icon" HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=}">
<Button Content="Content"/>
</labs:SettingsCard>
<labs:SettingsCard Header="SettingsCard" Description="Without an icon + IsClickEnabled" IsClickEnabled="True" >
<Button Content="Content"/>
</labs:SettingsCard>
<labs:SettingsCard Header="SettingsCard" Description="Left aligned" HeaderIcon="{ui:FontIcon FontFamily={StaticResource SymbolThemeFontFamily}, Glyph=}">
<Button Content="Content"/>
<labs:SettingsCard.Resources>
<Thickness x:Key="SettingsExpanderItemPadding">16,8,44,8</Thickness>
</labs:SettingsCard.Resources>
</labs:SettingsCard>
</labs:SettingsExpander.Items>
</labs:SettingsExpander> As you can see, we have different left-spacing variations (red) while also having (slightly) different right-spacing variations to e.g. show the ActionButton in a consistent way when the SettingsCard is part of a SettingsExpander (yellow). Now, for normal usage - a developer wouldn't need to worry about all of this - as the controls handle these variations out of the box. But the lightweight overriding of styles does provide additional flexibility!
Well, by default the Header/Description will be left-aligned - leaving no whitespace (but it will when the SettingsCard is part of the SettingsExpander.Items). In case a developer would like to override this there's no need to set the margin of the control - but by overriding the SettingsCardLeftIndention: <labs:SettingsCard Header="SettingsCard" Description="Without an icon but with left indention">
<labs:SettingsCard.Resources>
<x:Double x:Key="SettingsCardLeftIndention">120</x:Double>
</labs:SettingsCard.Resources>
</labs:SettingsCard> Additionally, this can be set on the UserControl/Page/App level as well so all SettingsCards would adhere to this automagically. I might have missed your point on the MinWidth stuff - so please let me know if you see another use case that'd be relevant and that we do not support yet!
Hah good point :)! Will have a look what other controls across WinUI use :)! Hope this helps! |
FYI @niels9001 |
The ItemsRepeater.ItemTemplate property allows using a |
@YourOrdinaryCat great suggestion. Would you like to submit a PR for that? Thanks! |
Done - see #417, would a new sample be needed for this? If not I can mark it as ready for review already. |
@YourOrdinaryCat Thanks! We've been wanting to add some more sample anyway, so if you wanted to show how to use a |
@leoshusar is this with UWP or WindowsAppSDK? In either case can you report this with the Visual Studio tools? There isn't anything special we should have to be doing for this; these are standard setups for these components, so this would have to be something within the VS tooling or the platform itself. |
My guess is that this is done to align with the behavior in WinUI - here's an example from the NavigationView source, and the docs. The As a workaround, you could create a specialized collection (e.g namespace MyCollections;
using CommunityToolkit.Labs;
using System.Collections.ObjectModel;
public sealed class SettingsCardCollection : ObservableCollection<SettingsCard> { } <Page ...
xmlns:labs="using:CommunityToolkit.Labs"
xmlns:col="using:MyCollections">
<labs:SettingsExpander>
<labs:SettingsExpander.ItemsSource>
<col:SettingsCardCollection>
<labs:SettingsCard />
<labs:SettingsCard />
<labs:SettingsCard />
</col:SettingsCardCollection>
</labs:SettingsExpander.ItemsSource>
</labs:SettingsExpander>
</Page> |
Thanks for the workaround! So since it's currently impossible (?) to instantiate the Also I'd like to propose small feature request. I'm currently trying to recreate something like this: Any thoughts on this? |
We are porting over these triggers to our new CommunityToolkit repo, so feel free to open an issue here: https://github.com/CommunityToolkit/Windows/issues
@michael-hawker Since there were quite some changes related to this along the way, I can't recall exactly why we went for
We wanted to make the For your particular use case, this works: <labs:SettingsExpander.ItemsFooter>
<labs:SettingsCard Header="Choose a device" Style="{StaticResource DefaultSettingsExpanderItemStyle}">
<Button Content="Add a device" />
</labs:SettingsCard>
</labs:SettingsExpander.ItemsFooter> Make sure you reference the file that contains the <Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///CommunityToolkit.Labs.WinUI.SettingsControls/SettingsExpander/SettingsExpander.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources> I've created a PR to tweak the ItemsSource sample as I can imagine this is a frequent ask: #433 |
@niels9001 |
Is this the issue you're referring to? microsoft/microsoft-ui-xaml#1809 I do wish this was updated on WinAppSDK, specially because I think Either way, switching to |
FYI @niels9001 for the height thing. Also, did we swap the base collection initialization to be an ObservableCollection over a List? |
Hey @niels9001 - just asking - it's noted that this is labeled "experimental", which can deter people from actually using it now. Any estimate to when this (and related elements) will be stable? |
The In the future we'd like to have (and follow :)) a more structured approach to 'graduate' Labs experiments into the main Toolkit. |
Hi, I'm seeing an issue where SettingsExpander doesn't respect a specified CornerRadius. Here's some exaggerated, modified Dev Home code. As you can see, the SettingsCard gets a radius, but the SettingsExpander doens't change. Is this a bug, or should the radius be modified a different way?
|
@krschau is this using the latest build out of the main repo https://github.com/CommunityToolkit/Windows? FYI @niels9001 |
@krschau The |
This was shipped in the 8.0 Release, please update to use that version of the component. Any further issues/requests should start in the main repository. |
Approved from Toolkit
Problem Statement:
THere are currently no controls in WinUI or the Toolkit that allows for creating consistent settings experiences that can be found across Windows 11. This experiment introduces a SettingsCard component that allows to display simple cards.
SettingsExpander will be an follow-up experiment to introduce collapsible cards.
Overview
This experiment adds the following components:
IsClickEnabled
property can be used to turn it into a Button-like control.SettingsCard
, andSettingsCard
can be used to set the SettingsExpander.Items. Binding is also supported.Media1.mp4
Using
You can try it out via the NuGet Packages here:
SettingsCard (doc + samples)
SettingsExpander (doc + samples)
Read more about Preview Packages here.
CommunityToolkit members can also try it out with Codespaces.
TO DO
Implementation Requirements
Not all these items are required to submit a PR. This list is here to help track what is remaining to implement before a technical review and discussion of moving into the main repository can occur.
Tested Platforms
Technical Review
These items can sometimes be done ahead of time, but are usually started and completed after all implementation details are finished.
The text was updated successfully, but these errors were encountered: