dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

Frame offsets inner content view by 1pt #23333

Closed filipnavara closed 1 week ago

filipnavara commented 3 months ago

Description

The Frame control implements the IBorderElement interface and unconditionally returns IBorderElement.BorderWidth => 1 whether the border is visible or not. The default color for the border is null.

In Xamarin.Forms you could make a round frame by instantiation Frame with IsClippedToBounds = true, CornerRadius = N/2, WidthRequest = N, HeightRequest = N (roughly) and the inner content view set to the Content property would be clipped to a circle.

In MAUI, however, the inner view is offset by the IBorderElement.BorderWidth during layout. If you set BackgroundColor to Colors.Tan and then the background of the inner content to something else, you'll notice that the "border area" remains tan despite the frame having no border set.

Example of the visual artifact:

image

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.61 SR6.1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

Yes, implement IBorderElement.BorderWidth in our control derived from Frame and return 0.

Relevant log output

No response

github-actions[bot] commented 3 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

PureWeen commented 3 months ago

@filipnavara TBH this probably won't get scheduled any time soon.

We're marking Frame as obsolete in .NET9 so that's where we'll be putting most of our effort

filipnavara commented 3 months ago

I filed the issue mostly to make it easy to search for a workaround, and I don’t expect it to get any prioritisation at all. Once I figured the root cause the workaround was just 8 lines of code in our project.