From 8c5d9e7c235556172e9ba67a62ebff5758be075c Mon Sep 17 00:00:00 2001 From: ProJend Date: Sun, 1 Dec 2024 19:54:58 +0800 Subject: [PATCH 1/8] Make content fully stretch the available area --- components/SettingsControls/src/SettingsCard/SettingsCard.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml index 3d2e4dd3..a3678397 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml @@ -198,8 +198,8 @@ - + @@ -308,6 +308,7 @@ + From 176ac15ca88245995508377e82b4b9b8fe1c945c Mon Sep 17 00:00:00 2001 From: ProJend Date: Tue, 3 Dec 2024 18:21:57 +0800 Subject: [PATCH 2/8] Add 'VisualState' for stretching Content --- .../src/SettingsCard/SettingsCard.xaml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml index a3678397..50a7be23 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml @@ -198,8 +198,8 @@ - - + + @@ -360,6 +360,17 @@ + + + + + + + + + + + From 7969f5a7314fd3dd962a974ff40c73eab69aab14 Mon Sep 17 00:00:00 2001 From: ProJend Date: Tue, 3 Dec 2024 21:03:15 +0800 Subject: [PATCH 3/8] Add 'MaxWidth' target to wrap header --- components/SettingsControls/src/SettingsCard/SettingsCard.xaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml index 50a7be23..79b13a9a 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml @@ -102,6 +102,7 @@ 12 20 0 + 477 120 2,0,20,0 14,0,0,0 @@ -369,6 +370,7 @@ + From 791ab3afc41d6a9dd648290368584d1aa8fc6b75 Mon Sep 17 00:00:00 2001 From: ProJend Date: Wed, 4 Dec 2024 13:57:02 +0800 Subject: [PATCH 4/8] Add property Horizontal ContentAlignment to SettingsCard --- .../src/SettingsCard/SettingsCard.Properties.cs | 6 +++++- .../SettingsControls/src/SettingsCard/SettingsCard.cs | 2 ++ .../SettingsControls/src/SettingsCard/SettingsCard.xaml | 7 ++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs b/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs index 6152a04e..8d408a2e 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs @@ -190,5 +190,9 @@ public enum ContentAlignment /// /// The Content is vertically aligned. /// - Vertical + Vertical, + /// + /// The Content is horizontally aligned. + /// + Horizontal } diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.cs b/components/SettingsControls/src/SettingsCard/SettingsCard.cs index 6e1e064b..222d8828 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.cs +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.cs @@ -26,6 +26,7 @@ namespace CommunityToolkit.WinUI.Controls; [TemplateVisualState(Name = RightWrappedNoIconState, GroupName = ContentAlignmentStates)] [TemplateVisualState(Name = LeftState, GroupName = ContentAlignmentStates)] [TemplateVisualState(Name = VerticalState, GroupName = ContentAlignmentStates)] +[TemplateVisualState(Name = HorizontalState, GroupName = ContentAlignmentStates)] [TemplateVisualState(Name = NoContentSpacingState, GroupName = ContentSpacingStates)] [TemplateVisualState(Name = ContentSpacingState, GroupName = ContentSpacingStates)] @@ -44,6 +45,7 @@ public partial class SettingsCard : ButtonBase internal const string RightWrappedNoIconState = "RightWrappedNoIcon"; internal const string LeftState = "Left"; internal const string VerticalState = "Vertical"; + internal const string HorizontalState = "Horizontal"; internal const string ContentSpacingStates = "ContentSpacingStates"; internal const string NoContentSpacingState = "NoContentSpacing"; diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml index 79b13a9a..175b93fb 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml @@ -362,10 +362,11 @@ - - + + - + From a1a3a6324b1efea6c872137bdcc1fe3ef611a174 Mon Sep 17 00:00:00 2001 From: ProJend Date: Wed, 4 Dec 2024 17:43:11 +0800 Subject: [PATCH 5/8] Add sample SettingsCard with Horizontal ContentAlignment --- .../samples/SettingsExpanderSample.xaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/components/SettingsControls/samples/SettingsExpanderSample.xaml b/components/SettingsControls/samples/SettingsExpanderSample.xaml index 7c96fb97..aee8e6ca 100644 --- a/components/SettingsControls/samples/SettingsExpanderSample.xaml +++ b/components/SettingsControls/samples/SettingsExpanderSample.xaml @@ -65,6 +65,34 @@ + + + 550 + 700 + + + + + + + + + + + + From 14d982150906cba177b5747f6549bab1a938ce26 Mon Sep 17 00:00:00 2001 From: ProJend Date: Sun, 8 Dec 2024 21:34:42 +0800 Subject: [PATCH 6/8] Simplify RightAlignedCompactToggleSwitchStyle --- .../src/SettingsCard/SettingsCard.xaml | 624 +----------------- 1 file changed, 7 insertions(+), 617 deletions(-) diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml index 175b93fb..bb63321f 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.xaml +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.xaml @@ -1,4 +1,4 @@ - + - - - From 082620fab0134a78c25a2da7a4e6190a14fd36c8 Mon Sep 17 00:00:00 2001 From: ProJend Date: Tue, 10 Dec 2024 14:18:45 +0800 Subject: [PATCH 7/8] Add sample for SettingsCard.ContentAlignment property --- .../ContentAlignmentSettingsCardSample.xaml | 125 ++++++++++++++++++ ...ContentAlignmentSettingsCardSample.xaml.cs | 17 +++ .../SettingsControls/samples/SettingsCard.md | 8 +- .../samples/SettingsCardSample.xaml | 14 +- .../samples/SettingsControls.Samples.csproj | 9 ++ .../samples/SettingsExpander.md | 2 - .../samples/SettingsExpanderSample.xaml | 64 --------- 7 files changed, 158 insertions(+), 81 deletions(-) create mode 100644 components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml create mode 100644 components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml.cs diff --git a/components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml b/components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml new file mode 100644 index 00000000..b16a5636 --- /dev/null +++ b/components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml @@ -0,0 +1,125 @@ + + + + + + 800 + 600 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml.cs b/components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml.cs new file mode 100644 index 00000000..4fa3234a --- /dev/null +++ b/components/SettingsControls/samples/ContentAlignmentSettingsCardSample.xaml.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace SettingsControlsExperiment.Samples; + +[ToolkitSampleBoolOption("IsCardEnabled", true, Title = "Is Enabled")] + +[ToolkitSample(id: nameof(ContentAlignmentSettingsCardSample), "ContentAlignmentSettingsCardSample", description: "A sample for showing how to use the SettingsCard.ContentAlignment attached property")] + +public sealed partial class ContentAlignmentSettingsCardSample : Page +{ + public ContentAlignmentSettingsCardSample() + { + this.InitializeComponent(); + } +} diff --git a/components/SettingsControls/samples/SettingsCard.md b/components/SettingsControls/samples/SettingsCard.md index 667bc703..cab4d336 100644 --- a/components/SettingsControls/samples/SettingsCard.md +++ b/components/SettingsControls/samples/SettingsCard.md @@ -12,11 +12,15 @@ issue-id: 0 icon: Assets/SettingsCard.png --- -SettingsCard is a control that can be used to display settings in your experience. It uses the default styling found in Windows 11 and is easy to use, meets all accessibility standards and will make your settings page look great! +`SettingsCard` is a control that can be used to display settings in your experience. It uses the default styling found in Windows 11 and is easy to use, meets all accessibility standards and will make your settings page look great! You can set the `Header`, `Description`, `HeaderIcon` and `Content` properties to create an easy to use experience, like so: > [!SAMPLE SettingsCardSample] -SettingsCard can also be turned into a button, by setting the `IsClickEnabled` property. This can be useful whenever you want your settings component to navigate to a detail page or open an external link. You can set a custom icon by setting the `ActionIcon`, or hiding it completely by setting the `IsActionIconVisible` to `false`. +`SettingsCard` can also be turned into a button, by setting the `IsClickEnabled` property. This can be useful whenever you want your settings component to navigate to a detail page or open an external link. You can set a custom icon by setting the `ActionIcon`, or hiding it completely by setting the `IsActionIconVisible` to `false`. > [!SAMPLE ClickableSettingsCardSample] + +You can easily override certain properties to create custom experiences. For instance, you can customize the `ContentAlignment` of a `SettingsCard`, to align your content to the Right (default), Left (hiding the `HeaderIcon`, `Header` and `Description`), Vertically (usually best paired with changing the `HorizontalContentAlignment` to `Stretch`) or Horizontally (attaching additional `VisualState` to reverse the Content layout). + +> [!SAMPLE ContentAlignmentSettingsCardSample] diff --git a/components/SettingsControls/samples/SettingsCardSample.xaml b/components/SettingsControls/samples/SettingsCardSample.xaml index 6e17962d..583bd122 100644 --- a/components/SettingsControls/samples/SettingsCardSample.xaml +++ b/components/SettingsControls/samples/SettingsCardSample.xaml @@ -1,4 +1,4 @@ - + - - - 800 - 600 - - - - From 250159068acc9fb337af11633d90674a1a88e07b Mon Sep 17 00:00:00 2001 From: ProJend Date: Tue, 10 Dec 2024 14:18:53 +0800 Subject: [PATCH 8/8] Add more SettingsCard in SettingsExpander --- .../samples/SettingsExpanderSample.xaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/SettingsControls/samples/SettingsExpanderSample.xaml b/components/SettingsControls/samples/SettingsExpanderSample.xaml index 97758b21..c2a9ae43 100644 --- a/components/SettingsControls/samples/SettingsExpanderSample.xaml +++ b/components/SettingsControls/samples/SettingsExpanderSample.xaml @@ -1,4 +1,4 @@ - +