Skip to content

Commit

Permalink
Update All (most) BindableProperty XML docs (#14704)
Browse files Browse the repository at this point in the history
  • Loading branch information
hartez committed Jun 7, 2023
1 parent d692a88 commit dc5e780
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
80 changes: 78 additions & 2 deletions src/Controls/src/Core/Border.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,87 @@ public Thickness Padding

/// <summary>Bindable property for <see cref="StrokeShape"/>.</summary>
public static readonly BindableProperty StrokeShapeProperty =
BindableProperty.Create(nameof(StrokeShape), typeof(IShape), typeof(Border), new Rectangle());
BindableProperty.Create(nameof(StrokeShape), typeof(IShape), typeof(Border), new Rectangle(),
propertyChanging: (bindable, oldvalue, newvalue) =>
{
if (newvalue is not null)
(bindable as Border)?.StopNotifyingStrokeShapeChanges();
},
propertyChanged: (bindable, oldvalue, newvalue) =>
{
if (newvalue is not null)
(bindable as Border)?.NotifyStrokeShapeChanges();
});

void NotifyStrokeShapeChanges()
{
var strokeShape = StrokeShape;

if (strokeShape is VisualElement visualElement)
{
SetInheritedBindingContext(visualElement, BindingContext);
visualElement.Parent = this;
_strokeShapeChanged ??= (sender, e) => OnPropertyChanged(nameof(StrokeShape));
_strokeShapeProxy ??= new();
_strokeShapeProxy.Subscribe(visualElement, _strokeShapeChanged);
}
}

void StopNotifyingStrokeShapeChanges()
{
var strokeShape = StrokeShape;

if (strokeShape is VisualElement visualElement)
{
SetInheritedBindingContext(visualElement, null);
visualElement.Parent = null;
_strokeShapeProxy?.Unsubscribe();
}
}

/// <summary>Bindable property for <see cref="Stroke"/>.</summary>
public static readonly BindableProperty StrokeProperty =
BindableProperty.Create(nameof(Stroke), typeof(Brush), typeof(Border), null);
BindableProperty.Create(nameof(Stroke), typeof(Brush), typeof(Border), null,
propertyChanging: (bindable, oldvalue, newvalue) =>
{
if (newvalue is not null)
(bindable as Border)?.StopNotifyingStrokeChanges();
},
propertyChanged: (bindable, oldvalue, newvalue) =>
{
if (newvalue is not null)
(bindable as Border)?.NotifyStrokeChanges();
});

void NotifyStrokeChanges()
{
var stroke = Stroke;

if (stroke is ImmutableBrush)
return;

if (stroke is not null)
{
SetInheritedBindingContext(stroke, BindingContext);
_strokeChanged ??= (sender, e) => OnPropertyChanged(nameof(Stroke));
_strokeProxy ??= new();
_strokeProxy.Subscribe(stroke, _strokeChanged);
}
}

void StopNotifyingStrokeChanges()
{
var stroke = Stroke;

if (stroke is ImmutableBrush)
return;

if (stroke is not null)
{
SetInheritedBindingContext(stroke, null);
_strokeProxy?.Unsubscribe();
}
}

/// <summary>Bindable property for <see cref="StrokeThickness"/>.</summary>
public static readonly BindableProperty StrokeThicknessProperty =
Expand Down
1 change: 1 addition & 0 deletions src/Controls/src/Core/MenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public partial class MenuItem : BaseMenuItem, IMenuItemController, IStyleSelecta
public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(MenuItem), default(ImageSource));

static readonly BindablePropertyKey IsEnabledPropertyKey = BindableProperty.CreateReadOnly(nameof(IsEnabled), typeof(bool), typeof(MenuItem), true);

/// <summary>Bindable property for <see cref="IsEnabled"/>.</summary>
public static readonly BindableProperty IsEnabledProperty = IsEnabledPropertyKey.BindableProperty;

Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Shapes/Shape.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using System;
using System.Linq;
using System.Numerics;
Expand Down

0 comments on commit dc5e780

Please sign in to comment.