Skip to content

Commit

Permalink
Add Bindable Properties
Browse files Browse the repository at this point in the history
  • Loading branch information
brminnick committed Nov 30, 2022
1 parent ad17181 commit cf1cf10
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
44 changes: 40 additions & 4 deletions src/CommunityToolkit.Maui/Converters/IsInRangeConverter.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,56 @@ public sealed class IsInRangeConverter : IsInRangeConverter<object>
/// <summary>Converts the incoming value to a <see cref="bool"/> indicating whether or not the value is within a range.</summary>
public abstract class IsInRangeConverter<TObject> : BaseConverterOneWay<IComparable, object>
{
/// <summary>
/// Bindable property for <see cref="MinValue"/>
/// </summary>
public static readonly BindableProperty MinValueProperty = BindableProperty.Create(nameof(MinValue), typeof(IComparable), typeof(IsInRangeConverter<TObject>));

/// <summary>
/// Bindable property for <see cref="MaxValue"/>
/// </summary>
public static readonly BindableProperty MaxValueProperty = BindableProperty.Create(nameof(MaxValue), typeof(IComparable), typeof(IsInRangeConverter<TObject>));

/// <summary>
/// Bindable property for <see cref="TrueObject"/>
/// </summary>
public static readonly BindableProperty TrueObjectProperty = BindableProperty.Create(nameof(TrueObject), typeof(TObject?), typeof(IsInRangeConverter<TObject>));

/// <summary>
/// Bindable property for <see cref="FalseObject"/>
/// </summary>
public static readonly BindableProperty FalseObjectProperty = BindableProperty.Create(nameof(FalseObject), typeof(TObject?), typeof(IsInRangeConverter<TObject>));

/// <inheritdoc/>
public override object DefaultConvertReturnValue { get; set; } = new();

/// <summary>Minimum value.</summary>
public IComparable? MinValue { get; set; }
public IComparable? MinValue
{
get => (IComparable?)GetValue(MinValueProperty);
set => SetValue(MinValueProperty, value);
}

/// <summary>Maximum value.</summary>
public IComparable? MaxValue { get; set; }
public IComparable? MaxValue
{
get => (IComparable?)GetValue(MaxValueProperty);
set => SetValue(MaxValueProperty, value);
}

/// <summary>The object that corresponds to True value.</summary>
public TObject? TrueObject { get; set; }
public TObject? TrueObject
{
get => (TObject?)GetValue(TrueObjectProperty);
set => SetValue(TrueObjectProperty, value);
}

/// <summary>The object that corresponds to False value.</summary>
public TObject? FalseObject { get; set; }
public TObject? FalseObject
{
get => (TObject?)GetValue(FalseObjectProperty);
set => SetValue(FalseObjectProperty, value);
}

/// <summary>Converts an object that implemented IComparable to a <see cref="bool"/> based on the object being within a <see cref="MinValue"/> and <see cref="MaxValue"/> range.</summary>
/// <param name="value">The value to convert.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace CommunityToolkit.Maui.Extensions;

/// <inheritdoc />
public abstract class ValueConverterExtension : IMarkupExtension<ICommunityToolkitValueConverter>
public abstract class ValueConverterExtension : BindableObject, IMarkupExtension<ICommunityToolkitValueConverter>
{
/// <inheritdoc />
public ICommunityToolkitValueConverter ProvideValue(IServiceProvider serviceProvider)
Expand Down

0 comments on commit cf1cf10

Please sign in to comment.