Skip to content
Merged
5 changes: 3 additions & 2 deletions src/Controls/src/Core/ActivityIndicator/ActivityIndicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Diagnostics;

using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
Expand All @@ -16,7 +17,7 @@ namespace Microsoft.Maui.Controls
public partial class ActivityIndicator : View, IColorElement, IElementConfiguration<ActivityIndicator>, IActivityIndicator
{
/// <summary>Bindable property for <see cref="IsRunning"/>.</summary>
public static readonly BindableProperty IsRunningProperty = BindableProperty.Create(nameof(IsRunning), typeof(bool), typeof(ActivityIndicator), default(bool));
public static readonly BindableProperty IsRunningProperty = BindableProperty.Create(nameof(IsRunning), typeof(bool), typeof(ActivityIndicator), BooleanBoxes.FalseBox);
Comment thread
pictos marked this conversation as resolved.

/// <summary>Bindable property for <see cref="Color"/>.</summary>
public static readonly BindableProperty ColorProperty = ColorElement.ColorProperty;
Expand Down Expand Up @@ -48,7 +49,7 @@ public Color Color
public bool IsRunning
{
get { return (bool)GetValue(IsRunningProperty); }
set { SetValue(IsRunningProperty, value); }
set { SetValue(IsRunningProperty, BooleanBoxes.Box(value)); }
}

/// <inheritdoc/>
Expand Down
5 changes: 3 additions & 2 deletions src/Controls/src/Core/AppLinkEntry.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable disable
using System;
using System.Collections.Generic;
using Microsoft.Maui.Controls.Internals;

namespace Microsoft.Maui.Controls
{
Expand Down Expand Up @@ -28,7 +29,7 @@ public AppLinkEntry()
public static readonly BindableProperty AppLinkUriProperty = BindableProperty.Create(nameof(AppLinkUri), typeof(Uri), typeof(AppLinkEntry), null);

/// <summary>Bindable property for <see cref="IsLinkActive"/>.</summary>
public static readonly BindableProperty IsLinkActiveProperty = BindableProperty.Create(nameof(IsLinkActive), typeof(bool), typeof(AppLinkEntry), false);
public static readonly BindableProperty IsLinkActiveProperty = BindableProperty.Create(nameof(IsLinkActive), typeof(bool), typeof(AppLinkEntry), BooleanBoxes.FalseBox);

/// <summary>Gets or sets an application-specific URI that uniquely describes content within an app. This is a bindable property.</summary>
public Uri AppLinkUri
Expand All @@ -49,7 +50,7 @@ public string Description
public bool IsLinkActive
{
get { return (bool)GetValue(IsLinkActiveProperty); }
set { SetValue(IsLinkActiveProperty, value); }
set { SetValue(IsLinkActiveProperty, BooleanBoxes.Box(value)); }
}

/// <summary>Gets a dictionary of application-specific key-value pairs.</summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/src/Core/Cells/Cell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class Cell : Element, ICellController, IFlowDirectionController,
/// <summary>The default height of cells.</summary>
public const int DefaultCellHeight = 40;
/// <summary>Bindable property for <see cref="IsEnabled"/>.</summary>
public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Cell), true, propertyChanged: OnIsEnabledPropertyChanged);
public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Cell), BooleanBoxes.TrueBox, propertyChanged: OnIsEnabledPropertyChanged);

ObservableCollection<MenuItem> _contextActions;
List<MenuItem> _currentContextActions;
Expand Down Expand Up @@ -130,7 +130,7 @@ public double Height
public bool IsEnabled
{
get { return (bool)GetValue(IsEnabledProperty); }
set { SetValue(IsEnabledProperty, value); }
set { SetValue(IsEnabledProperty, BooleanBoxes.Box(value)); }
}

/// <summary>Gets the height of the rendered cell on the device.</summary>
Expand Down
5 changes: 3 additions & 2 deletions src/Controls/src/Core/Cells/SwitchCell.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable disable
using System;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
Expand All @@ -9,7 +10,7 @@ namespace Microsoft.Maui.Controls
public class SwitchCell : Cell
{
/// <summary>Bindable property for <see cref="On"/>.</summary>
public static readonly BindableProperty OnProperty = BindableProperty.Create(nameof(On), typeof(bool), typeof(SwitchCell), false, propertyChanged: (obj, oldValue, newValue) =>
public static readonly BindableProperty OnProperty = BindableProperty.Create(nameof(On), typeof(bool), typeof(SwitchCell), BooleanBoxes.FalseBox, propertyChanged: (obj, oldValue, newValue) =>
{
var switchCell = (SwitchCell)obj;
switchCell.OnChanged?.Invoke(obj, new ToggledEventArgs((bool)newValue));
Expand All @@ -32,7 +33,7 @@ public Color OnColor
public bool On
{
get { return (bool)GetValue(OnProperty); }
set { SetValue(OnProperty, value); }
set { SetValue(OnProperty, BooleanBoxes.Box(value)); }
}

/// <summary>Gets or sets the text displayed next to the switch. This is a bindable property.</summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Controls/src/Core/CheckBox/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class CheckBox : View, IElementConfiguration<CheckBox>, IBorderEl

/// <summary>Bindable property for <see cref="IsChecked"/>. This is a bindable property.</summary>
public static readonly BindableProperty IsCheckedProperty =
BindableProperty.Create(nameof(IsChecked), typeof(bool), typeof(CheckBox), false,
BindableProperty.Create(nameof(IsChecked), typeof(bool), typeof(CheckBox), BooleanBoxes.FalseBox,
propertyChanged: (bindable, oldValue, newValue) =>
{
if (bindable is not CheckBox checkBox)
Expand Down Expand Up @@ -98,7 +98,7 @@ public Color Color
public bool IsChecked
{
get => (bool)GetValue(IsCheckedProperty);
set => SetValue(IsCheckedProperty, value);
set => SetValue(IsCheckedProperty, BooleanBoxes.Box(value));
}

protected internal override void ChangeVisualState()
Expand Down Expand Up @@ -175,7 +175,7 @@ void ICommandElement.CanExecuteChanged(object sender, EventArgs e) =>
bool ICheckBox.IsChecked
{
get => IsChecked;
set => SetValue(IsCheckedProperty, value, SetterSpecificity.FromHandler);
set => SetValue(IsCheckedProperty, BooleanBoxes.Box(value), SetterSpecificity.FromHandler);
}

ICommand ICommandElement.Command => Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class ListViewAdapter : CellAdapter
static int s_dividerHorizontalDarkId = int.MinValue;

#pragma warning disable CS0618 // Type or member is obsolete
internal static readonly BindableProperty IsSelectedProperty = BindableProperty.CreateAttached("IsSelected", typeof(bool), typeof(Cell), false);
internal static readonly BindableProperty IsSelectedProperty = BindableProperty.CreateAttached("IsSelected", typeof(bool), typeof(Cell), BooleanBoxes.FalseBox);
#pragma warning restore CS0618 // Type or member is obsolete

readonly Context _context;
Expand Down Expand Up @@ -722,7 +722,7 @@ void Select(int index, AView view)
Cell previousCell;
#pragma warning restore CS0618 // Type or member is obsolete
if (_selectedCell.TryGetTarget(out previousCell))
previousCell.SetValue(IsSelectedProperty, false);
previousCell.SetValue(IsSelectedProperty, BooleanBoxes.FalseBox);
}

_lastSelected = view;
Expand All @@ -733,7 +733,7 @@ void Select(int index, AView view)
#pragma warning disable CS0618 // Type or member is obsolete
Cell cell = GetCellForPosition(index);
#pragma warning restore CS0618 // Type or member is obsolete
cell.SetValue(IsSelectedProperty, true);
cell.SetValue(IsSelectedProperty, BooleanBoxes.TrueBox);
#pragma warning disable CS0618 // Type or member is obsolete
_selectedCell = new WeakReference<Cell>(cell);
#pragma warning restore CS0618 // Type or member is obsolete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void OnDrawerStateChanged(object sender, DrawerStateChangedEventArgs e)

void OnDrawerOpened(object sender, DrawerOpenedEventArgs e)
{
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, true);
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, BooleanBoxes.TrueBox);
}

void OnDrawerSlide(object sender, DrawerSlideEventArgs e)
Expand All @@ -95,7 +95,7 @@ void OnDrawerSlide(object sender, DrawerSlideEventArgs e)

void OnDrawerClosed(object sender, DrawerClosedEventArgs e)
{
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, false);
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, BooleanBoxes.FalseBox);
}

#endregion IDrawerListener
Expand Down Expand Up @@ -319,7 +319,7 @@ protected virtual void UpdateDrawerLockMode(FlyoutBehavior behavior)
{
case FlyoutBehavior.Disabled:
CloseDrawers();
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, false);
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, BooleanBoxes.FalseBox);
_currentLockMode = LockModeLockedClosed;
SetDrawerLockMode(_currentLockMode);
_content.SetPadding(0, _content.PaddingTop, _content.PaddingRight, _content.PaddingBottom);
Expand All @@ -332,7 +332,7 @@ protected virtual void UpdateDrawerLockMode(FlyoutBehavior behavior)
break;

case FlyoutBehavior.Locked:
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, true);
Shell.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, BooleanBoxes.TrueBox);
_currentLockMode = LockModeLockedOpen;
SetDrawerLockMode(_currentLockMode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Input;
using CoreGraphics;
using Foundation;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Graphics.Platform;
using UIKit;
Expand Down Expand Up @@ -704,7 +705,7 @@ void LeftBarButtonItemHandler(UIViewController controller, bool isRootPage)
}
else if (_flyoutBehavior == FlyoutBehavior.Flyout)
{
_context?.Shell?.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, true);
_context?.Shell?.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, BooleanBoxes.TrueBox);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Controls/src/Core/CompressedLayout.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable disable
using System;
using System.ComponentModel;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
Expand All @@ -27,7 +28,7 @@ public static bool GetIsHeadless(BindableObject bindable)
/// <param name="value">The new layout compression value. <see langword="true" /> to enable layout compression</param>
[Obsolete("CompressedLayout does not provide meaningful functionality and may be removed in a future release. Please remove usage of this API.")]
public static void SetIsHeadless(BindableObject bindable, bool value)
=> bindable.SetValue(IsHeadlessProperty, value);
=> bindable.SetValue(IsHeadlessProperty, BooleanBoxes.Box(value));

static void OnIsHeadlessPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
Expand Down
5 changes: 3 additions & 2 deletions src/Controls/src/Core/ContentPage/ContentPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Diagnostics;

using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.HotReload;
using Microsoft.Maui.Layouts;
Expand All @@ -27,7 +28,7 @@ public View Content

/// <summary>Bindable property for <see cref="HideSoftInputOnTapped"/>.</summary>
public static readonly BindableProperty HideSoftInputOnTappedProperty
= BindableProperty.Create(nameof(HideSoftInputOnTapped), typeof(bool), typeof(ContentPage), false);
= BindableProperty.Create(nameof(HideSoftInputOnTapped), typeof(bool), typeof(ContentPage), BooleanBoxes.FalseBox);

/// <summary>Bindable property for <see cref="SafeAreaEdges"/>.</summary>
public static readonly BindableProperty SafeAreaEdgesProperty = SafeAreaElement.SafeAreaEdgesProperty;
Expand All @@ -38,7 +39,7 @@ public static readonly BindableProperty HideSoftInputOnTappedProperty
public bool HideSoftInputOnTapped
{
get { return (bool)GetValue(HideSoftInputOnTappedProperty); }
set { SetValue(HideSoftInputOnTappedProperty, value); }
set { SetValue(HideSoftInputOnTappedProperty, BooleanBoxes.Box(value)); }
}

/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions src/Controls/src/Core/DragAndDrop/DragGestureRecognizer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Windows.Input;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
using System.Windows.Input;

namespace Microsoft.Maui.Controls
{
Expand All @@ -11,7 +12,7 @@ namespace Microsoft.Maui.Controls
public class DragGestureRecognizer : GestureRecognizer
{
/// <summary>Bindable property for <see cref="CanDrag"/>.</summary>
public static readonly BindableProperty CanDragProperty = BindableProperty.Create(nameof(CanDrag), typeof(bool), typeof(DragGestureRecognizer), true);
public static readonly BindableProperty CanDragProperty = BindableProperty.Create(nameof(CanDrag), typeof(bool), typeof(DragGestureRecognizer), BooleanBoxes.TrueBox);

/// <summary>Bindable property for <see cref="DropCompletedCommand"/>.</summary>
public static readonly BindableProperty DropCompletedCommandProperty = BindableProperty.Create(nameof(DropCompletedCommand), typeof(ICommand), typeof(DragGestureRecognizer), null);
Expand Down Expand Up @@ -52,7 +53,7 @@ public DragGestureRecognizer()
public bool CanDrag
{
get { return (bool)GetValue(CanDragProperty); }
set { SetValue(CanDragProperty, value); }
set { SetValue(CanDragProperty, BooleanBoxes.Box(value)); }
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/Controls/src/Core/DragAndDrop/DropGestureRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Maui.Controls.Internals;

namespace Microsoft.Maui.Controls
{
Expand All @@ -14,7 +15,7 @@ namespace Microsoft.Maui.Controls
public class DropGestureRecognizer : GestureRecognizer
{
/// <summary>Bindable property for <see cref="AllowDrop"/>.</summary>
public static readonly BindableProperty AllowDropProperty = BindableProperty.Create(nameof(AllowDrop), typeof(bool), typeof(DropGestureRecognizer), true);
public static readonly BindableProperty AllowDropProperty = BindableProperty.Create(nameof(AllowDrop), typeof(bool), typeof(DropGestureRecognizer), BooleanBoxes.TrueBox);

/// <summary>Bindable property for <see cref="DragOverCommand"/>.</summary>
public static readonly BindableProperty DragOverCommandProperty = BindableProperty.Create(nameof(DragOverCommand), typeof(ICommand), typeof(DropGestureRecognizer), null);
Expand Down Expand Up @@ -62,7 +63,7 @@ public DropGestureRecognizer()
public bool AllowDrop
{
get { return (bool)GetValue(AllowDropProperty); }
set { SetValue(AllowDropProperty, value); }
set { SetValue(AllowDropProperty, BooleanBoxes.Box(value)); }
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/src/Core/Entry/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public partial class Entry : InputView, ITextAlignmentElement, IEntryController,
/// <summary>
/// Backing store for the <see cref="IsPassword"/> property.
/// </summary>
public static readonly BindableProperty IsPasswordProperty = BindableProperty.Create(nameof(IsPassword), typeof(bool), typeof(Entry), default(bool));
public static readonly BindableProperty IsPasswordProperty = BindableProperty.Create(nameof(IsPassword), typeof(bool), typeof(Entry), BooleanBoxes.FalseBox);

/// <inheritdoc cref="InputView.TextProperty"/>
public new static readonly BindableProperty TextProperty = InputView.TextProperty;
Expand Down Expand Up @@ -122,7 +122,7 @@ public TextAlignment VerticalTextAlignment
public bool IsPassword
{
get { return (bool)GetValue(IsPasswordProperty); }
set { SetValue(IsPasswordProperty, value); }
set { SetValue(IsPasswordProperty, BooleanBoxes.Box(value)); }
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/Controls/src/Core/FlyoutPage/FlyoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ namespace Microsoft.Maui.Controls
public partial class FlyoutPage : Page, IFlyoutPageController, IElementConfiguration<FlyoutPage>, IFlyoutView
{
/// <summary>Bindable property for <see cref="IsGestureEnabled"/>.</summary>
public static readonly BindableProperty IsGestureEnabledProperty = BindableProperty.Create(nameof(IsGestureEnabled), typeof(bool), typeof(FlyoutPage), true);
public static readonly BindableProperty IsGestureEnabledProperty = BindableProperty.Create(nameof(IsGestureEnabled), typeof(bool), typeof(FlyoutPage), BooleanBoxes.TrueBox);

/// <summary>Bindable property for <see cref="IsPresented"/>.</summary>
public static readonly BindableProperty IsPresentedProperty = BindableProperty.Create(nameof(IsPresented), typeof(bool), typeof(FlyoutPage), default(bool),
public static readonly BindableProperty IsPresentedProperty = BindableProperty.Create(nameof(IsPresented), typeof(bool), typeof(FlyoutPage), BooleanBoxes.FalseBox,
propertyChanged: OnIsPresentedPropertyChanged, propertyChanging: OnIsPresentedPropertyChanging, defaultValueCreator: GetDefaultValue);

/// <summary>Bindable property for <see cref="FlyoutLayoutBehavior"/>.</summary>
Expand Down Expand Up @@ -95,14 +95,14 @@ public Page Detail
public bool IsGestureEnabled
{
get { return (bool)GetValue(IsGestureEnabledProperty); }
set { SetValue(IsGestureEnabledProperty, value); }
set { SetValue(IsGestureEnabledProperty, BooleanBoxes.Box(value)); }
}

/// <summary>Gets or sets a value that indicates whether the flyout is presented. This is a bindable property.</summary>
public bool IsPresented
{
get { return (bool)GetValue(IsPresentedProperty); }
set { SetValue(IsPresentedProperty, value); }
set { SetValue(IsPresentedProperty, BooleanBoxes.Box(value)); }
}

/// <summary>Gets or sets the flyout page that is used to present a menu or navigation options.</summary>
Expand Down Expand Up @@ -282,7 +282,7 @@ internal static void UpdateFlyoutLayoutBehavior(FlyoutPage page)
{
if (page is IFlyoutPageController fpc && fpc.ShouldShowSplitMode)
{
page.SetValue(IsPresentedProperty, true);
page.SetValue(IsPresentedProperty, BooleanBoxes.TrueBox);
if (page.FlyoutLayoutBehavior != FlyoutLayoutBehavior.Default)
fpc.CanChangeIsPresented = false;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Controls/src/Core/FontImageSource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable disable
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
Expand Down Expand Up @@ -57,13 +58,13 @@ public double Size

/// <summary>Bindable property for <see cref="FontAutoScalingEnabled"/>.</summary>
public static readonly BindableProperty FontAutoScalingEnabledProperty =
BindableProperty.Create(nameof(FontAutoScalingEnabled), typeof(bool), typeof(FontImageSource), false,
BindableProperty.Create(nameof(FontAutoScalingEnabled), typeof(bool), typeof(FontImageSource), BooleanBoxes.FalseBox,
propertyChanged: (b, o, n) => ((FontImageSource)b).OnSourceChanged());

public bool FontAutoScalingEnabled
{
get => (bool)GetValue(FontAutoScalingEnabledProperty);
set => SetValue(FontAutoScalingEnabledProperty, value);
set => SetValue(FontAutoScalingEnabledProperty, BooleanBoxes.Box(value));
}
}
}
Loading
Loading