Browse Source

add missing documentation.

pull/4069/head
Dan Walmsley 6 years ago
parent
commit
29c575e6d9
  1. 49
      src/Avalonia.Controls/ToggleSwitch.cs

49
src/Avalonia.Controls/ToggleSwitch.cs

@ -8,31 +8,52 @@ using Avalonia.LogicalTree;
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary> /// <summary>
/// A WinUi like ToggleSwitch control. /// A Toggle Switch control.
/// </summary> /// </summary>
///
public class ToggleSwitch : ToggleButton public class ToggleSwitch : ToggleButton
{ {
static ToggleSwitch()
{
OffContentProperty.Changed.AddClassHandler<ToggleSwitch>((x, e) => x.OffContentChanged(e));
OnContentProperty.Changed.AddClassHandler<ToggleSwitch>((x, e) => x.OnContentChanged(e));
}
/// <summary>
/// Defines the <see cref="OffContent"/> property.
/// </summary>
public static readonly StyledProperty<object> OffContentProperty = public static readonly StyledProperty<object> OffContentProperty =
AvaloniaProperty.Register<ToggleSwitch, object>(nameof(OffContent), defaultValue:"Off"); AvaloniaProperty.Register<ToggleSwitch, object>(nameof(OffContent), defaultValue: "Off");
/// <summary>
/// Defines the <see cref="OffContentTemplate"/> property.
/// </summary>
public static readonly StyledProperty<IDataTemplate> OffContentTemplateProperty = public static readonly StyledProperty<IDataTemplate> OffContentTemplateProperty =
AvaloniaProperty.Register<ToggleSwitch, IDataTemplate>(nameof(OffContentTemplate)); AvaloniaProperty.Register<ToggleSwitch, IDataTemplate>(nameof(OffContentTemplate));
/// <summary>
/// Defines the <see cref="OnContent"/> property.
/// </summary>
public static readonly StyledProperty<object> OnContentProperty = public static readonly StyledProperty<object> OnContentProperty =
AvaloniaProperty.Register<ToggleSwitch, object>(nameof(OnContent), defaultValue: "On"); AvaloniaProperty.Register<ToggleSwitch, object>(nameof(OnContent), defaultValue: "On");
/// <summary>
/// Defines the <see cref="OnContentTemplate"/> property.
/// </summary>
public static readonly StyledProperty<IDataTemplate> OnContentTemplateProperty = public static readonly StyledProperty<IDataTemplate> OnContentTemplateProperty =
AvaloniaProperty.Register<ToggleSwitch, IDataTemplate>(nameof(OnContentTemplate)); AvaloniaProperty.Register<ToggleSwitch, IDataTemplate>(nameof(OnContentTemplate));
/// <summary>
/// Gets or Sets the Content that is displayed when in the On State.
/// </summary>
public object OnContent public object OnContent
{ {
get { return GetValue(OnContentProperty); } get { return GetValue(OnContentProperty); }
set { SetValue(OnContentProperty, value); } set { SetValue(OnContentProperty, value); }
} }
/// <summary>
/// Gets or Sets the Content that is displayed when in the Off State.
/// </summary>
public object OffContent public object OffContent
{ {
get { return GetValue(OffContentProperty); } get { return GetValue(OffContentProperty); }
@ -51,13 +72,18 @@ namespace Avalonia.Controls
private set; private set;
} }
/// <summary>
/// Gets or Sets the <see cref="IDataTemplate"/> used to display the <see cref="OffContent"/>.
/// </summary>
public IDataTemplate OffContentTemplate public IDataTemplate OffContentTemplate
{ {
get { return GetValue(OffContentTemplateProperty); } get { return GetValue(OffContentTemplateProperty); }
set { SetValue(OffContentTemplateProperty, value); } set { SetValue(OffContentTemplateProperty, value); }
} }
/// <summary>
/// Gets or Sets the <see cref="IDataTemplate"/> used to display the <see cref="OnContent"/>.
/// </summary>
public IDataTemplate OnContentTemplate public IDataTemplate OnContentTemplate
{ {
get { return GetValue(OnContentTemplateProperty); } get { return GetValue(OnContentTemplateProperty); }
@ -90,13 +116,6 @@ namespace Avalonia.Controls
} }
} }
static ToggleSwitch()
{
OffContentProperty.Changed.AddClassHandler<ToggleSwitch>((x, e) => x.OffContentChanged(e));
OnContentProperty.Changed.AddClassHandler<ToggleSwitch>((x, e) => x.OnContentChanged(e));
}
protected override bool RegisterContentPresenter(IContentPresenter presenter) protected override bool RegisterContentPresenter(IContentPresenter presenter)
{ {
var result = base.RegisterContentPresenter(presenter); var result = base.RegisterContentPresenter(presenter);
@ -114,6 +133,6 @@ namespace Avalonia.Controls
return result; return result;
} }
} }
} }

Loading…
Cancel
Save