Skip to content

How can I trigger an event at UserControl when I click a button on Page. #21378

Answered by fire-eggs
athinawesome asked this question in General
Discussion options

You must be logged in to vote

What you need to do is register your event handler to the control which will raise the event.  Also called “subscribing” to the event.

You mention that you have a Button on your Page which you want to raise the event. That button needs to have its GeoViewTapped handler set to your MyMapViewOnGeoViewTapped function. The fact that said function is in your UserControl isn’t important, as long as the Page has an instance of the UserControl.

I’m not sufficiently familar with Xamarin.Forms to know whether the method is called “OnLoad”, or “LoadView”, etc. At some point in the Page logic, your Button control has been created: _after_ that point, you register the event handler.  Then, when the bu…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants