WP7 How Trap Move From Page

Nov 1, 2010 at 5:04 AM

I'm using Alex Yakhnin's progress dialog. I hide it in a async return. If the user clicks the back button it never gets hidden.

I need some thing like OnDeactivate or a way of determining when the user is moving away from my page.

Any ideas?



Nov 1, 2010 at 10:21 PM

Do you mean IResult (coroutines)? I don't know the component you mentioned, but if you are implementing an IResult, in the execute method you have access to the executing VM through the ActionExecutionContext. You might subscribe to IDeactivate.Deactivated event to force the dialog shutdown.  

Nov 1, 2010 at 10:32 PM

Figured this one out:


        public HouseListPageViewModel(INavigationService navigationService)
            _navigationService = navigationService;

            _navigationService.Navigating += (s, e) =>
                if (e.NavigationMode == NavigationMode.Back)
                    if (progress != null && progress.Visibility == Visibility.Visible)


Nov 2, 2010 at 9:35 AM

Good solution. You might also consider detaching the event handler on progress completion and navigation completed: since NavigationService is a singleton maybe it could leak the IResult.