Simulate Button/View Tap Event from Code



I want to simulate a button or view ‘ontap’ programmatically at runtime. I have situations wherein when I open a page, I would like to have the onTap event tied to a button, which is dependent on the navigation context, to be executed. Since the onTap event to be run can change, I can’t just call the event directly.

I have searched and can’t seem to find a solution.

Kind regards.


I’m not sure I’m 100% following you but do you just want to run different code in the onTap event based on some data that is sent over when the page was navigated to?


Hi Nick,

No. What I wanted was:

  1. page1 -> navigates to page2
  2. page1 simulates a tap of a button on page2

In the process of trying to create an example, I just realized that I was going about the process the wrong way. I had a mental picture of using the ‘handle’ to a created page to call an event on the page. Just occurred to me that NS doesn’t work like that. Pages are navigated to, without returning a ‘handle’ to the page. All post page processing should happen in the pages’ navigate/loaded events.

Let me test it out.


I think you’re on the right track now. Whatever business logic you need to perform should be run inside navigated to or the loaded event.


Hi Nick,

That’s the route I followed and its going well.

Thanks, your earlier comment sent me in the right direction.

Kind regards.