dotnet / dotnet/maui

Border StrokeShape should be a Geometry, not a Shape

Open
#3,558 10 comments 0 reactions 1 assignee Claimed by @jsuarezruiz View on GitHub
area-drawing proposal/open s/triaged s/verified t/enhancement ☀️
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

This is an API design oversight, I believe. The `Border` component has properties, such as `Stroke`, `StrokeThickness`, `Fill` etc. The border shape is specified via the `StrokeShape` property of type `IShape`. The implementing `Shape` class also has properties, such as `Stroke`, `StrokeThickness`, `Fill` etc. This is really confusing, because it is not known which set of properties is respected.

In my humble opinion, the correct type of the stroke shape should be `Geometry`, similar to what we use for the `Clip` property. In fact, it would be nice to clip the inner contents of the `Border` to that `Geometry`. For consistency, the property should be renamed to `StrokeGeometry` as well.

In addition to this, I believe it is not very convenient to require specifying the border shape always, to see any border on the screen. If the border shape is not specified, it should default to a rectangular border, as this is the most common use case.

### API Changes

1. Remove or make obsolete the `StrokeShape` property of the `Border` class.
2. Add a new property `StrokeGeometry` of type `Geometry` to the `Border` class.
3. Make the `StrokeGeometry` optional, defaulting to a `RectangleGeometry`, if not specified.

### Usage Scenarios

```csharp
var border = new Border
{
Stroke = new SolidColorBrush(Colors.Red),
StrokeGeometry = new RectangleGeometry(),
StrokeThickness = 5
};
```

```xaml



```

### Backward Compatibility

If the original `StrokeShape` property is made obsolete, then the backward compatibility can be maintained. I vote for introducing a breaking change by removing the `StrokeShape` property and replacing it with the new `StrokeGeometry` property, however. Having a brand new framework with some legacy APIs from day one is not very good in my books.

### Difficulty

Medium

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.