Skip to content

Commit 6f3e840

Browse files
committed
API documentation for the Snackbar
1 parent 2326871 commit 6f3e840

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

MaterialDesignThemes.Wpf/Snackbar.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
namespace MaterialDesignThemes.Wpf
1212
{
13+
/// <summary>
14+
/// Implements a <see cref="Snackbar"/> according to the Material Design specs. Instances are considered for a single-use Snackbar.
15+
/// </summary>
1316
[TemplateVisualState(GroupName = VisibilityStatesGroupName, Name = HiddenStateName)]
1417
[TemplateVisualState(GroupName = VisibilityStatesGroupName, Name = VisibleStateName)]
1518
public class Snackbar : Control
@@ -100,6 +103,10 @@ public override void OnApplyTemplate()
100103
base.OnApplyTemplate();
101104
}
102105

106+
/// <summary>
107+
/// Shows this <see cref="Snackbar"/> inside its parent <see cref="SnackbarHost"/>.
108+
/// </summary>
109+
/// <returns></returns>
103110
public async Task Show()
104111
{
105112
if (State != SnackbarState.Initialized)
@@ -123,6 +130,10 @@ public async Task Show()
123130
_timer.Start();
124131
}
125132

133+
/// <summary>
134+
/// Hides this <see cref="Snackbar"/>.
135+
/// </summary>
136+
/// <returns></returns>
126137
public async Task Hide()
127138
{
128139
if (State != SnackbarState.Visible)

MaterialDesignThemes.Wpf/SnackbarAction.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66

77
namespace MaterialDesignThemes.Wpf
88
{
9+
/// <summary>
10+
/// An optional parameter for the <see cref="SnackbarHost.ShowAsync(object, string, SnackbarAction)"/> method to provide an action for the <see cref="Snackbar"/>.
11+
/// A <see cref="ActionLabel"/> is mandatory to label the action button.
12+
/// The <see cref="ActionHandler"/> is an optional event handler, which will be called by clicking the action button.
13+
/// </summary>
914
public class SnackbarAction
1015
{
1116
private string _actionLabel;
1217
private SnackbarActionEventHandler _actionHandler;
1318

19+
/// <summary>
20+
/// Optional event handler, which will be called by clicking the action button.
21+
/// </summary>
1422
public SnackbarActionEventHandler ActionHandler
1523
{
1624
get
@@ -19,6 +27,9 @@ public SnackbarActionEventHandler ActionHandler
1927
}
2028
}
2129

30+
/// <summary>
31+
/// Mandatory label for the action button.
32+
/// </summary>
2233
public string ActionLabel
2334
{
2435
get
@@ -27,8 +38,17 @@ public string ActionLabel
2738
}
2839
}
2940

41+
/// <summary>
42+
/// Creates a new instance.
43+
/// </summary>
44+
/// <param name="actionLabel">Mandatory label for the action button.</param>
3045
public SnackbarAction(string actionLabel) : this(actionLabel, null) { }
3146

47+
/// <summary>
48+
/// Creates a new instance.
49+
/// </summary>
50+
/// <param name="actionLabel">Mandatory label for the action button.</param>
51+
/// <param name="actionHandler">Optional event handler, which will be called by clicking the action button.</param>
3252
public SnackbarAction(string actionLabel, SnackbarActionEventHandler actionHandler)
3353
{
3454
_actionLabel = actionLabel;

MaterialDesignThemes.Wpf/SnackbarHost.cs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace MaterialDesignThemes.Wpf
1010
{
11+
/// <summary>
12+
/// A control which wraps itself around content and hosts the popup of <see cref="Snackbar"/> instances over this content.
13+
/// </summary>
1114
public class SnackbarHost : ContentControl
1215
{
1316
public const string SnackbarHostRootName = "SnackbarHostRoot";
@@ -17,15 +20,17 @@ public class SnackbarHost : ContentControl
1720
public static readonly DependencyProperty IdentifierProperty = DependencyProperty.Register(nameof(Identifier), typeof(object), typeof(SnackbarHost), new PropertyMetadata(default(object)));
1821

1922
/// <summary>
20-
/// Identifier which is used in conjunction with <see cref="Show(object)"/> to determine where a dialog should be shown.
23+
/// Identifier which is used in conjunction with <see cref="Show(object)"/> to determine where a <see cref="Snackbar"/> should be shown.
2124
/// </summary>
2225
public object Identifier
2326
{
24-
get {
27+
get
28+
{
2529
return GetValue(IdentifierProperty);
2630
}
2731

28-
set {
32+
set
33+
{
2934
SetValue(IdentifierProperty, value);
3035
}
3136
}
@@ -60,21 +65,45 @@ private void UnloadedHandler(object sender, RoutedEventArgs routedEventArgs)
6065
LoadedInstances.Remove(this);
6166
}
6267

68+
/// <summary>
69+
/// Shows a <see cref="Snackbar"/>. To use, <see cref="SnackbarHost"/> instance must be in a visual tree (typically this may be specified towards the root of a Window's XAML).
70+
/// </summary>
71+
/// <param name="message">The message to show in the Snackbar.</param>
72+
/// <returns></returns>
6373
public static async Task ShowAsync(string message)
6474
{
6575
await ShowAsync(null, message, null);
6676
}
6777

78+
/// <summary>
79+
/// Shows a <see cref="Snackbar"/>. To use, <see cref="SnackbarHost"/> instance must be in a visual tree (typically this may be specified towards the root of a Window's XAML).
80+
/// </summary>
81+
/// <param name="hostIdentifier"><see cref="Identifier"/> of the instance where the Snackbar should be shown. Typically this will match an identifer set in XAML. <c>null</c> is allowed.</param>
82+
/// <param name="message">The message to show in the Snackbar.</param>
83+
/// <returns></returns>
6884
public static async Task ShowAsync(object hostIdentifier, string message)
6985
{
7086
await ShowAsync(hostIdentifier, message, null);
7187
}
7288

89+
/// <summary>
90+
/// Shows a <see cref="Snackbar"/>. To use, <see cref="SnackbarHost"/> instance must be in a visual tree (typically this may be specified towards the root of a Window's XAML).
91+
/// </summary>
92+
/// <param name="message">The message to show in the Snackbar.</param>
93+
/// <param name="snackbarAction">Optional action for the Snackbar. See <see cref="SnackbarAction"/> for details.</param>
94+
/// <returns></returns>
7395
public static async Task ShowAsync(string message, SnackbarAction snackbarAction)
7496
{
7597
await ShowAsync(null, message, snackbarAction);
7698
}
7799

100+
/// <summary>
101+
/// Shows a <see cref="Snackbar"/>. To use, <see cref="SnackbarHost"/> instance must be in a visual tree (typically this may be specified towards the root of a Window's XAML).
102+
/// </summary>
103+
/// <param name="hostIdentifier"><see cref="Identifier"/> of the instance where the Snackbar should be shown. Typically this will match an identifer set in XAML. <c>null</c> is allowed.</param>
104+
/// <param name="message">The message to show in the Snackbar.</param>
105+
/// <param name="snackbarAction">Optional action for the Snackbar. See <see cref="SnackbarAction"/> for details.</param>
106+
/// <returns></returns>
78107
public static async Task ShowAsync(object hostIdentifier, string message, SnackbarAction snackbarAction)
79108
{
80109
if (string.IsNullOrWhiteSpace(message))

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,8 @@
864864
</Setter>
865865
</Style>
866866

867-
<Style TargetType="{x:Type transitions:TransitioningContentBase}">
868-
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
867+
<Style TargetType="{x:Type transitions:TransitioningContentBase}">
868+
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
869869
<Setter Property="Template">
870870
<Setter.Value>
871871
<ControlTemplate TargetType="{x:Type transitions:TransitioningContentBase}">

0 commit comments

Comments
 (0)