I need to register a different chat listener for each page. I have 2 pages. I added the following code in each of them:
DataTransferManager.GetForCurrentView().DataRequested += App_DataRequested;
I added it to the constructor of one page and to the UserControl_Loaded event of the other (on the first page there is simply no UserControl_Loaded, so I added it directly to the constructor). At the moment when the second page is trying to load, I got an exception:
WinRT information: An event handler has already been registered
Additional information: A method was called at an unexpected time.
Where should I place it and what is the “right” time for this? It also looks strange that we have different DataTransferManager for each view, but only one is currently active. Even more, I noticed that if you add only one listener for the first page, other pages will be shared by this listener anyway. If I have only one common listener for all pages, is it correct to register it in app.xaml.cs?
source
share