Frage

What i use:

a list of 10 webbrowsers

a tabIndex ( index of current webbrowser)

different pages that use NavigationService.GoBack() to get to the Mainpage.

the problem:

everytime i use GoBack() to get to the mainpage and navigate, the Navigated-event will be fired 1 time more. Thats a huge performance issue after some surfing but i don't know why it's happening.

what i do in OnNavigatedTo:

fill the webbrowserlist if count != 10 (global list, only 1 time happening)

set Events for every browsers (maybe the problem, but can't imagine why)

thanks for your help.

War es hilfreich?

Lösung

If I understand your problem than it is that the webbrowsers Navigated event fires more and more time as you navigate back and forth between the pages.

Without seeing the code I would say that the problem is that you subscribe to the navigated event every time you navigate back to your main page. You could avoid this by:

1) Subscribing to the events in the main pages constructor, becuase it is getting called one time only

2) If you have to subscribe to the events in the pages OnNavigatedTo event than do this checking before:

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
                        if (e.NavigationMode != NavigationMode.Back)
                        {
                           webbrowser.tap += someFunction;
                        }
    }

if you need to register to the events every time you navigate to the page than to the following:

  protected override void OnNavigatedFrom(NavigationEventArgs e)
    {
       webbrowser.tap -= someFunction;
    } 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top