-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Core] Fix Border margin issue #14402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e9c2d2d
85fd6f8
dbdd371
e617a3e
ecd832a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)); | ||
| } | ||
|
|
@@ -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; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StrokeShape "only" needs the information to define the Shape to use for the border and to clip the content. It uses IShape so Shapes and Geometries can be used. This, apart from cause confusion, has problems:
To improve this situation, we should apply changes to use Geometry or, if we want to make it easier to use and avoid requiring setting sizes, etc., create a new type like IStrokeShape that defines only the Shape without having properties to manage colors, stroke, etc. In In case of choose this second option, I would also ask, does it make sense to allow using a Line for example? I think having Rectangle, RoundRectangle, Ellipse and Path covers all scenarios.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the only property we need to update ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, is the only one impacting in the size. The rest are not used because we don't apply colors or any other effect; just use the defined path to draw the Border. |
||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using a Shape in the
StrokeShapeproperty, we didn't have theStrokeTicknessmapped from the Border to the Shape.