Caliburn Micro and RadPhoneApplicationFrame

5 posts, 0 answers
  1. Derek
    Derek avatar
    39 posts
    Member since:
    Aug 2012

    Posted 06 Jun 2012 Link to this post

    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();
           }
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 12 Jun 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. Derek
    Derek avatar
    39 posts
    Member since:
    Aug 2012

    Posted 12 Jun 2012 Link to this post

    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.
  5. Todor
    Admin
    Todor avatar
    778 posts

    Posted 15 Jun 2012 Link to this post

    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 >>

  6. Derek
    Derek avatar
    39 posts
    Member since:
    Aug 2012

    Posted 15 Jun 2012 Link to this post

    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;
            }
Back to Top
DevCraft banner