How do I move GPS watcher to App.xaml superclass and Dispatch events to other pages/classes?

久未见 提交于 2019-12-04 14:57:08

Use PhoneApplicationPage methods OnNavigatedTo() and OnNavigatedFrom() to register/unregister position receiving. Watcher object may be defined in the Application class as you plan. Individual pages can use static property Application.Current to access Application object.

I think you have all you need.

BTW, you should not need event dispatching as the GeoCoordinateWatcher delivers events in the UI thread context.

A side remark: We (Resco) just published an update to our Location library. Maybe this article could give you some idea what can be done with GPS and location-based services.

You could use a messaging system when the position or status changes. All relevant pages could subscribe to such messages.

Alternatively, depending on the structure of your app, you could have the events handled centrally and applied to a shared viewmodel which is referred to by the other pages.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!