This is a migrated thread and some comments may be shown as answers.

Caliburn Micro and RadPhoneApplicationFrame

4 Answers 81 Views
PhoneApplicationFrame
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Derek
Top achievements
Rank 1
Derek asked on 07 Jun 2012, 01:32 AM
For some reason using RadPhoneApplicationFrame with CM causes OnDeactivate to fire twice when navigating to another Page when the ViewModel inherits from Screen.

If I set:
radPhoneApplicationFrame.HoldNavigationUntilExitTransitionIsFinished = false; 

...the problem goes away but the transitions don't work properly.

update: I figured out why this happens but I'm not sure how to fix it yet.

"I noticed that when using the RadPhoneApplicationFrame, OnDeactivate will fire twice when navigating.  This happens because the RadPhoneApplicationFrame registers the Navigating event and by default it saves off the target Uri and cancels navigation so the transition animation can complete.  Once that happens it navigates to the saved off Uri which causes OnDeactivate to fire again."

A possible fix might be to register the Navigating event in the ctor instead of the Loaded event.
private void RadPhoneApplicationFrame_Loaded(object sender, RoutedEventArgs e)
       {
           base.Navigating += new NavigatingCancelEventHandler(this.OnNavigating);
           this.HookOrientationChanged();
       }

4 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 12 Jun 2012, 03:09 PM
Hello,

Do you mean that the Deactivate of the application fires twice? This event should not fire when you are navigating between the pages, or maybe we are missing something from your scenario? Can you please elaborate a bit more - we are open to make changes in our code if it is required.

Kind regards, Valentin.Stoychev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Derek
Top achievements
Rank 1
answered on 12 Jun 2012, 03:17 PM
The problem is the RadPhoneApplicationFrame and the CM frame adapter both register Navigating.  The CM frame adapter registers it first so it gets fired first.  So, OnDeactivate gets fired by CM when Navigating fires, then the RadPhoneApplicationFrame Navigating event fires and it cancels navigation so the animation can finish.  Then the RadPhoneApplicationFrame Navigates and OnDeactivate fires again.  It's not really a problem with the RadPhoneApplicationFrame.  I think it can be worked around.  I did so with a cheesy hack but there is probably a better way.
0
Todor
Telerik team
answered on 15 Jun 2012, 11:11 AM
Hello Derek,

Thank you for the clarification. We were able to reproduce your scenario and we will see if we can modify the RadPhoneApplicationFrame so that OnDeactivate doesn't get fired twice. For now, your workaround seems to be the best solution.

However, if you find a better workaround it would be nice if you share it here with others which might be experiencing the same behavior.

All the best,
Todor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Derek
Top achievements
Rank 1
answered on 15 Jun 2012, 03:16 PM
In INavigationService I register the Loaded event for the frame.

frame.Loaded += FrameLoaded;

Then, when the event fires, un-register and re-register the Navigating event so the Navigating event for the frame fires first.  This seems to work but I haven't tested it much.  If you find a better way, let me know.  

private void FrameLoaded(object sender, RoutedEventArgs e)
        {
            frame.Loaded -= FrameLoaded;
            this.frame.Navigating -= OnNavigating;
            this.frame.Navigating += OnNavigating;
        }
Tags
PhoneApplicationFrame
Asked by
Derek
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Derek
Top achievements
Rank 1
Todor
Telerik team
Share this question
or