Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Added inline docs for MaxLengthReachedBehavior #882

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,35 @@

namespace Xamarin.CommunityToolkit.Behaviors
{
/// <summary>
/// The <see cref="MaxLengthReachedBehavior"/> is a behavior that allows the user to trigger an action when a user has reached the maximum length allowed on an <see cref="InputView"/>. It can either trigger a <see cref="ICommand"/> or an event depending on the user's preferred scenario.
/// </summary>
public class MaxLengthReachedBehavior : BaseBehavior<InputView>
{
/// <summary>
/// Backing BindableProperty for the <see cref="Command"/> property.
/// </summary>
public static readonly BindableProperty CommandProperty
= BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(MaxLengthReachedBehavior));

/// <summary>
/// Command that is triggered when the value configured in <see cref="InputView.MaxLength" /> is reached. Both the <see cref="MaxLengthReached"/> event and this command are triggered. This is a bindable property.
/// </summary>
public ICommand Command
{
get => (ICommand)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}

/// <summary>
/// Backing BindableProperty for the <see cref="ShouldDismissKeyboardAutomatically"/> property.
/// </summary>
public static readonly BindableProperty ShouldDismissKeyboardAutomaticallyProperty
= BindableProperty.Create(nameof(ShouldDismissKeyboardAutomatically), typeof(bool), typeof(MaxLengthReachedBehavior), false);

/// <summary>
/// Indicates whether or not the keyboard should be dismissed automatically after the maximum length is reached. This is a bindable property.
/// </summary>
public bool ShouldDismissKeyboardAutomatically
{
get => (bool)GetValue(ShouldDismissKeyboardAutomaticallyProperty);
Expand All @@ -29,6 +44,9 @@ public bool ShouldDismissKeyboardAutomatically

readonly WeakEventManager<MaxLengthReachedEventArgs> maxLengthReachedEventManager = new WeakEventManager<MaxLengthReachedEventArgs>();

/// <summary>
/// Event that is triggered when the value configured in <see cref="InputView.MaxLength" /> is reached. Both the <see cref="Command"/> and this event are triggered. This is a bindable property.
/// </summary>
public event EventHandler<MaxLengthReachedEventArgs> MaxLengthReached
{
add => maxLengthReachedEventManager.AddEventHandler(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

namespace Xamarin.CommunityToolkit.Behaviors
{
/// <summary>
/// Container object for the event arguments that are provided when the <see cref="MaxLengthReachedBehavior.MaxLengthReached"/> event is triggered.
/// </summary>
public class MaxLengthReachedEventArgs : EventArgs
{
/// <summary>
/// The new text value as determined by the <see cref="MaxLengthReachedBehavior"/>
/// </summary>
public string Text { get; }

/// <summary>
/// Constructor to create a new instance of <see cref="MaxLengthReachedEventArgs"/>.
/// </summary>
/// <param name="text">The new text value as determined by the <see cref="MaxLengthReachedBehavior"/></param>
public MaxLengthReachedEventArgs(string text)
=> Text = text;
}
Expand Down