diff --git a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs index f1e87a4..6296a27 100644 --- a/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs +++ b/src/Ursa/Controls/OverlayShared/OverlayDialogHost.Shared.cs @@ -77,7 +77,7 @@ public partial class OverlayDialogHost: Canvas }; if (modal) { - rec[!Shape.FillProperty] = this[!OverlayMaskBrushProperty]; + rec[!PureRectangle.BackgroundProperty] = this[!OverlayMaskBrushProperty]; } else if(canCloseOnClick) { diff --git a/src/Ursa/Controls/Shapes/PureRectangle.cs b/src/Ursa/Controls/Shapes/PureRectangle.cs index b36dbd1..1dbdc33 100644 --- a/src/Ursa/Controls/Shapes/PureRectangle.cs +++ b/src/Ursa/Controls/Shapes/PureRectangle.cs @@ -1,4 +1,5 @@ using Avalonia; +using Avalonia.Controls; using Avalonia.Controls.Shapes; using Avalonia.Media; @@ -7,29 +8,23 @@ namespace Ursa.Controls.Shapes; /// /// A rectangle, with no corner radius. /// -public class PureRectangle: Shape +public class PureRectangle: Control { + public static readonly StyledProperty BackgroundProperty = AvaloniaProperty.Register( + nameof(Background)); + + public IBrush? Background + { + get => GetValue(BackgroundProperty); + set => SetValue(BackgroundProperty, value); + } static PureRectangle() { FocusableProperty.OverrideDefaultValue(false); - AffectsGeometry(BoundsProperty); - } - protected override Geometry? CreateDefiningGeometry() - { - StreamGeometry geometry = new StreamGeometry(); - Rect rect = new Rect(this.Bounds.Size).Deflate(this.StrokeThickness / 2.0); - using StreamGeometryContext context = geometry.Open(); - context.BeginFigure(new Point(rect.Left, rect.Top), true); - context.LineTo(new Point(rect.Right, rect.Top)); - context.LineTo(new Point(rect.Right, rect.Bottom)); - context.LineTo(new Point(rect.Left, rect.Bottom)); - context.LineTo(new Point(rect.Left, rect.Top)); - context.EndFigure(true); - return geometry; } - protected override Size MeasureOverride(Size availableSize) + public override void Render(DrawingContext context) { - return new Size(this.StrokeThickness, this.StrokeThickness); + context.DrawRectangle(Background, null, new Rect(Bounds.Size)); } } \ No newline at end of file