Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Add protected Accessor to VisualElement Constructor #12125

Merged

Conversation

SkyeHoefling
Copy link
Contributor

Description of Change

Updates the constructor of the VisualElement from internal to protected internal. This allows external code to inherit directly from the VisualElement instead of the View.

The Xamarin Community Toolkit requires access to some of the internal objects of the Xamarin.Forms platform. I am currently working on migrating the Popup Control Pull Request (#9616) to the Xamarin Community Toolkit (xamarin/XamarinCommunityToolkit#292) as I discussed with @PureWeen @jsuarezruiz and @jfversluis the other week. In the original Pull Request (#9616) to Xamarin.Forms @myroot suggested we have the BasePopup inherit from VisualElement instead of View. This would prevent developers from adding the BasePopup to a StackLayout since it's children accept a standard View. This feedback made a lot of sense and we updated that code to support VisualElement. Code Review Link.

Now that I am actively working on porting this code over to the Xamarin Community Toolkit I am unable to have the BasePopup inherit from VisualElement. If I try to use Element instead I am unable to properly implement the IVisualElementRenderer in the platform specific custom renderers. The BasePopup is not a View so it does not make sense to inherit directly from View,

I am not aware of the reason why this constructor was made internal, but I think it makes a lot of sense to open it up as I have done in this PR. This will allow developers to build their controls inheriting from VisualElement instead of View when it makes sense to do so.

Related GitHub Issues

Issues Resolved

N/A

API Changes

VisualElement

Changed:

  • internal VisualElement() => protected internal VisualElement()

Platforms Affected

  • Core/XAML (all platforms)

Behavioral/Visual Changes

None

Before/After Screenshots

Not applicable

Testing Procedure

Build still passes

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

@StephaneDelcroix StephaneDelcroix merged commit d59ddc9 into xamarin:5.0.0 Sep 22, 2020
@samhouts samhouts added the approved Has two approvals, no pending reviews, and no changes requested label Sep 22, 2020
@samhouts samhouts added this to the 5.0.0 milestone Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Has two approvals, no pending reviews, and no changes requested Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants