Skip to content

Commit 2e2f317

Browse files
authored
[SettingsExpander] Adding Expanded/Collapsed events (#382)
* Removing unused comments * Adding Expanded/Collapsed events * Adding comments * Bumping version number
1 parent baf07d8 commit 2e2f317

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

components/SettingsControls/samples/SettingsCardSample.xaml.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
namespace SettingsControlsExperiment.Samples;
66

77
[ToolkitSampleBoolOption("IsCardEnabled", true, Title = "Is Enabled")]
8-
// Single values without a colon are used for both label and value.
9-
// To provide a different label for the value, separate with a colon surrounded by a single space on both sides ("label : value").
10-
//[ToolkitSampleMultiChoiceOption("TextSize", title: "Text size", "Small : 12", "Normal : 16", "Big : 32")]
11-
//[ToolkitSampleMultiChoiceOption("TextFontFamily", title: "Font family", "Segoe UI", "Arial", "Consolas")]
12-
//[ToolkitSampleMultiChoiceOption("TextForeground", title: "Text foreground",
13-
// "Teal : #0ddc8c",
14-
// "Sand : #e7a676",
15-
// "Dull green : #5d7577")]
168

179
[ToolkitSample(id: nameof(SettingsCardSample), "SettingsCard", description: "A sample for showing how SettingsCard can be static or clickable.")]
1810
public sealed partial class SettingsCardSample : Page

components/SettingsControls/samples/SettingsExpanderSample.xaml.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ namespace SettingsControlsExperiment.Samples;
77
[ToolkitSampleBoolOption("IsCardExpanded", false, Title = "Is Expanded")]
88
// [ToolkitSampleBoolOption("IsCardEnabled", true, Title = "Is Enabled")] Disabled for now, see: https://github.com/CommunityToolkit/Labs-Windows/issues/362
99

10-
// Single values without a colon are used for both label and value.
11-
// To provide a different label for the value, separate with a colon surrounded by a single space on both sides ("label : value").
12-
//[ToolkitSampleMultiChoiceOption("TextSize", title: "Text size", "Small : 12", "Normal : 16", "Big : 32")]
13-
//[ToolkitSampleMultiChoiceOption("TextFontFamily", title: "Font family", "Segoe UI", "Arial", "Consolas")]
14-
//[ToolkitSampleMultiChoiceOption("TextForeground", title: "Text foreground",
15-
// "Teal : #0ddc8c",
16-
// "Sand : #e7a676",
17-
// "Dull green : #5d7577")]
18-
1910
[ToolkitSample(id: nameof(SettingsExpanderSample), "SettingsExpander", description: "The SettingsExpander can be used to group settings. SettingsCards can be customized in terms of alignment and content.")]
2011
public sealed partial class SettingsExpanderSample : Page
2112
{

components/SettingsControls/src/CommunityToolkit.Labs.WinUI.SettingsControls.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<ToolkitComponentName>SettingsControls</ToolkitComponentName>
44
<Description>This package contains the SettingsCard and SettingsExpander controls.</Description>
5-
<Version>0.0.16</Version>
5+
<Version>0.0.17</Version>
66
<LangVersion>10.0</LangVersion>
77

88
<!-- Rns suffix is required for namespaces shared across projects. See https://github.com/CommunityToolkit/Labs-Windows/issues/152 -->
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace CommunityToolkit.Labs.WinUI;
6+
public partial class SettingsExpander
7+
{
8+
/// <summary>
9+
/// Fires when the SettingsExpander is opened
10+
/// </summary>
11+
public event EventHandler? Expanded;
12+
13+
/// <summary>
14+
/// Fires when the expander is closed
15+
/// </summary>
16+
public event EventHandler? Collapsed;
17+
}

components/SettingsControls/src/SettingsExpander/SettingsExpander.Properties.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,14 @@ public bool IsExpanded
140140
protected virtual void OnIsExpandedPropertyChanged(bool oldValue, bool newValue)
141141
{
142142
OnIsExpandedChanged(oldValue, newValue);
143+
144+
if (newValue)
145+
{
146+
Expanded?.Invoke(this, EventArgs.Empty);
147+
}
148+
else
149+
{
150+
Collapsed?.Invoke(this, EventArgs.Empty);
151+
}
143152
}
144153
}

0 commit comments

Comments
 (0)