Reflect default value of IsClippedToBounds property #15894
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
In PR #11352, the default value is true when the IsClippedToBounds property value on the iOS side is not set, but the default value when the IsClippedToBounds property value is not set on the Android side is Element.CornerRadius > 0f.
This PR unifies the different default values for both iOS and Android.
If the IsClippedToBounds property is not specified on XAML, the default value is false as shown below.
[src\Controls\src\Core\Layout.cs]
Even in Xamarin.Forms, the default value of the Frame.IsClippedBounds property was false.
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.layout.isclippedtobounds?view=xamarin-forms#xamarin-forms-layout-isclippedtobounds
At least the current behavior does not correctly reflect the default value of IsClippedToBoundsProperty.
Below is the source code before the change.
[src\Controls\src\Core\Compatibility\Handlers\iOS\FrameRenderer.cs]
[src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs]
Below is the modified source code.
[src\Controls\src\Core\Compatibility\Handlers\iOS\FrameRenderer.cs]
[src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs]
Applying this PR has implications if the IsClippedToBounds property is not specified on the XAML.
Since iOS expects true as the default value, applying this PR results in false, which is different from the expected result.
Android expects to be true when CornerRadius is greater than 0, so applying this PR will result in a different result than expected.
Either way, on both iOS and Android, the results are different from what you might have expected so far.
Before applying this PR, you should consider what the default value of IsClippedToBounds should be.
After consideration, this PR should be applied if the current default value of false for the IsClippedToBounds property is followed.
I'll leave it up to you how you decide, because it has a big impact.
From the above, the execution results for Android and iOS are as follows.
[Android IsClippedToBounds unspecified]
[Android IsClippedToBounds = "True"]
[Android IsClippedToBounds = "False"]
[iOS IsClippedToBounds unspecified]
[iOS IsClippedToBounds = "True"]
[iOS IsClippedToBounds = "False"]
Issues Fixed
Fixes #15029