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

[MacOS] make OnElementChanged and OnElementPropertyChanged protected virtual#1187

Merged
StephaneDelcroix merged 2 commits intoxamarin:masterfrom
MichaelRumpler:master
Oct 17, 2017
Merged

[MacOS] make OnElementChanged and OnElementPropertyChanged protected virtual#1187
StephaneDelcroix merged 2 commits intoxamarin:masterfrom
MichaelRumpler:master

Conversation

@MichaelRumpler
Copy link
Contributor

@MichaelRumpler MichaelRumpler commented Oct 6, 2017

Description of Change

In Xamarin.Forms.Platform.MacOS the PageRenderer and ScrollViewRenderer did not have the usual protected virtual methods OnElementChanged and OnElementPropertyChanged. They were private and partly wrong named. Therefore users could not inherit from those renderers and use them as every other renderer on every other platform.

API Changes

Changed:

  • PageRenderer: void OnElementChanged => protected virtual void OnElementChanged
  • PageRenderer: void OnHandlePropertyChanged => protected virtual void OnElementPropertyChanged
  • ScrollViewRenderer: void OnElementChanged => protected virtual void OnElementChanged
  • ScrollViewRenderer: void HandlePropertyChanged => protected virtual void OnElementPropertyChanged

Behavioral Changes

None

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

Copy link
Member

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine for me, minus the comment

}

void OnElementChanged(VisualElementChangedEventArgs e)
protected virtual void OnElementChanged(VisualElementChangedEventArgs e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we try to not trigger events from virtual methods.

@MichaelRumpler
Copy link
Contributor Author

MichaelRumpler commented Oct 9, 2017

Good call, but you do raise ElementChanged yourself from CarouselPageRenderer.OnElementChanged, MasterDetailPageRenderer.OnElementChanged, NavigationPageRenderer.OnElementChanged, TabbedPageRenderer.OnElementChanged and even VisualElementRenderer.OnElementChanged.

I changed all the *PageRenderers and ScrollViewRenderer now. The event is now raised in the private Raise(or Handle-)ElementChanged method and the virtual OnElementChanged method is just an empty template method. Thus the ElementChanged event is still raised even if a derived class does not call base.OnElementChanged.

I did not change the VisualElementRenderer as this is used everywhere (also shared with iOS).

@StephaneDelcroix
Copy link
Member

StephaneDelcroix commented Oct 9, 2017

@MichaelRumpler

but you do raise ElementChanged yourself from CarouselPageRenderer.OnElementChanged, MasterDetailPageRenderer.OnElementChanged, NavigationPageRenderer.OnElementChanged, TabbedPageRenderer.OnElementChanged and even VisualElementRenderer.OnElementChanged.

and on BindableObject.PropertyChanged too... and you can't start to imagine how we regret it

@StephaneDelcroix StephaneDelcroix merged commit 347c340 into xamarin:master Oct 17, 2017
@samhouts samhouts added this to the 3.0.0 milestone May 5, 2018
@samhouts samhouts modified the milestones: 3.0.0, 2.5.0 Aug 23, 2019
PureWeen pushed a commit that referenced this pull request Oct 24, 2019
…virtual (#1187)

* make OnElementChanged and OnElementPropertyChanged protected virtual like all other renderers

* raise ElementChanged outside virtual OnElementChanged method
@samhouts samhouts modified the milestones: 3.0.0, 2.5.0 Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants