1

I have got a MainPage and a DetailPage. Both of them use a static class to receive their data. This class called DataService implements INotifyPropertyChanged interface and it implements a property called "IsLoading". Whenever a method within the DataService is invoked I set IsLoading to true. The DataService itself is contained in a static class called Globals which instantiances the DataService one (I know, I'm going to implement this with a singleton pattern)

On the MainPage their is a popup:

<Page.Resources>
  <Common:DataService x:Key="DataService" />
</Page.Resources>

<Popup IsOpen="{Binding IsLoading}" DataContext="{StaticResource DataService}">...</PopUp>

On the MainPage everything works fine. If the DataService requests something from the webservice, the popup is shown. If it is done, the popup hides.

If I change with Frame.Navigate(typeof(DetailPage)); and the DetailPage begins to invoke some methods of the dataservice, the popup is shown too, but not on the same page on as the main page. It will be display on the left top corner.

Funny part about that is: If I go back to the MainPage and it loads data, I'll get two popups. If I go again to the DetailPage, a third popup will be there and so on. It seems that this popup gets instantiated?!

Next point: When setting the DataContext of the Popup in OnNavigatingTo and removing the DataContext in OnNavigatingFrom I'll stay with the popup I want and no second one gets instantiated.

What goes wrong here?

4

0 回答 0