Skip to content

Commit

Permalink
[Core] Fix Border margin issue (#14402) Fixes #7764
Browse files Browse the repository at this point in the history
* Fox Border margin issue

* Auto-format source code

---------

Co-authored-by: GitHub Actions Autoformatter <[email protected]>
  • Loading branch information
jsuarezruiz and GitHub Actions Autoformatter authored Apr 20, 2023
1 parent 660784f commit 2b823f8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public BorderPage()
new BorderLayout(), Navigation),
GalleryBuilder.NavButton("Border Stroke options", () =>
new BorderStroke(), Navigation),
GalleryBuilder.NavButton("Border without Stroke", () =>
new Borderless(), Navigation),
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.Borderless"
BackgroundColor="Yellow"
Title="Border without Stroke">
<ContentPage.Resources>
<ResourceDictionary>

<Style x:Key="BorderlessStyle" TargetType="Border">
<Setter Property="StrokeThickness" Value="0" />
</Style>

</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid
RowDefinitions="*,*"
RowSpacing="0">
<Border
Background="Pink"
Style="{StaticResource BorderlessStyle}" />
<Border
Grid.Row="1"
Background="Red"
Style="{StaticResource BorderlessStyle}" />
</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample.Pages
{
public partial class Borderless : ContentPage
{
public Borderless()
{
InitializeComponent();
}
}
}
10 changes: 10 additions & 0 deletions src/Controls/src/Core/Border.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ protected override void OnPropertyChanged([CallerMemberName] string? propertyNam
propertyName == WidthProperty.PropertyName ||
propertyName == StrokeShapeProperty.PropertyName)
Handler?.UpdateValue(nameof(IBorderStroke.Shape));
else if (propertyName == StrokeThicknessProperty.PropertyName)
UpdateStrokeShape();
else if (propertyName == StrokeDashArrayProperty.PropertyName)
Handler?.UpdateValue(nameof(IBorderStroke.StrokeDashPattern));
}
Expand All @@ -312,5 +314,13 @@ void OnStrokeDashArrayChanged(object? sender, NotifyCollectionChangedEventArgs e
{
Handler?.UpdateValue(nameof(IBorderStroke.StrokeDashPattern));
}

void UpdateStrokeShape()
{
if (StrokeShape is Shape strokeShape)
{
strokeShape.StrokeThickness = StrokeThickness;
}
}
}
}

0 comments on commit 2b823f8

Please sign in to comment.