How to get current page in my WP7 app

后端 未结 2 1979
陌清茗
陌清茗 2021-02-05 04:14

Is there a way to get the active instance of the current page in my Windows Phone 7 app? I have been reading documentation and trying to figure it out to no avail.

In my

2条回答
  •  时光说笑
    2021-02-05 04:45

    You can get the current XAML page URL using NavigationService.CurrentSource http://msdn.microsoft.com/en-gb/library/system.windows.navigation.navigationservice.currentsource(v=VS.92).aspx

    However, to get the instance of the current page itself I think you'll need to maintain this yourself - one way would be to inherit all your pages from a shared abstract class which overrides OnNavigatedTo and then uses this as an opportunity to record itself with a singleton (maybe your App class)

提交回复
热议问题