Hi everyone,
I have a phone with a physical barcode scanner. Depending on which page the user currently is, the barcode scanner is enabled/disabled and an event handler is added/removed. The event is handled in the respective viewmodel of the page and different depending on the page (e.g. search article if you are on the page with the full article list or add article if you are on the page to create a new list).
I am using the Appearing and Disappearing Page event to add/remove the handler and enable/disable the scanner. However there are several problems that come up with that implementation.
First of all when the application starts, it automatically fires the Appearing event for each child of the TabbedPage (as intended I suppose). Thus it already adds all the event handlers even if only the one for the current page should be added. Furthermore when I change to another tab, the Disappearing event does not always trigger.
There are also pages that do not belong to the TabbedPage where the user can navigate to. These should also be able to influence the event handlers. But in this case, the events Appearing and Disappearing work fine.
So the main question is: How can I check when a specific page is navigated to and the previous one has disappeared? (for children of TabbedPage as well as pages independent of the TabbedPage)
My idea was to have a mixture of the CurrentPageChanged Event for the children of TabbedPage and to keep the Appearing/Disappearing for the independent pages. However this solution is far from optimal, thus I'd really appreciate any suggestions.
Regards,
Jeremy