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

Commit

Permalink
Added inline docs (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis authored and pictos committed Feb 14, 2021
1 parent 15b1be7 commit 0ad5dff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
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

0 comments on commit 0ad5dff

Please sign in to comment.