locked
Scrollviewer.ChangeView different behavior if disableAnimation is set

    Question

  • Hello,

    I am actually working on a simple project of reading a pdf file inside a windows 8.1 app. I started to implement a zoom using a scrollviewer, and I have a really strange behavior.

    If the parameter disableAnimation is set to false (default value), and I use the changeView function, it works perfectly.

    But, if I set the parameter disableAnimation to true, the changeView function with the exact same parameters send the viewport to a different offset.

    The code look like that:

    function ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e) { ScrollViewer viewer = sender as ScrollViewer; if (viewer != null && !e.IsIntermediate && !protection && viewer.ZoomFactor > this.ZoomFactor && this.RealZoomFactor <= 5) { protection = true; rootPage.NotifyUser("Rendering page...", NotifyType.StatusMessage); this.ZoomFactor = viewer.ZoomFactor; await RenderPDFPage(); this.ScrollViewer.ViewChanged -= ScrollViewer_ViewChanged; // case 1 ScrollViewer.ChangeView(ScrollViewer.HorizontalOffset, ScrollViewer.VerticalOffset, 1.0f); // case 2 ScrollViewer.ChangeView(ScrollViewer.HorizontalOffset, ScrollViewer.VerticalOffset, 1.0f, true); // the 2 other parameters have the same value. This function is called once after the pinch action

    this.ZoomFactor = 1.0f; rootPage.NotifyUser("Rendered page ", NotifyType.StatusMessage); protection = false; } }

    There is no other ChangeView in the code. And it doesn't work when the view is on bottom right.

    Thanks :)


    • Edited by BatRocchia Tuesday, March 11, 2014 9:57 AM more information
    Tuesday, March 11, 2014 9:54 AM

All replies

  • Is this causing a problem for your app?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, March 11, 2014 6:59 PM
    Moderator
  • Is this causing a problem for your app?
    Yes. If the user try to zoom somewhere in the pdf document, the view is magically translated to an other place. And this only happen when I remove the animation. (Btw I want to remove the animation to avoid clipping)
    Wednesday, March 12, 2014 4:06 PM
  • Can you provide a reproduction app?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, March 12, 2014 4:15 PM
    Moderator
  • The link of the project with the steps to reproduce the error.

    https://onedrive.live.com/redir?resid=8A5E4DF5C0ECCE8%211309

    Wednesday, March 12, 2014 6:08 PM
  • I can reproduce the problem. However, I can't tell what the difference is between having scrollviewer animation enabled and disabled - what exactly does it do in this case?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, March 12, 2014 7:28 PM
    Moderator
  • When the scrollviewer animation is enabled, if the ChangeView function has a translation, the user can see a translation effect. When the scrollviewer animation is disable, the view is directly translated without any graphic effect. This is just a graphic effect.

    In my program, I remove the animation because I change the parameter in the view, and I don't want the user to see the difference.

    My final goal is just to create a pdf reader sample in C# with zoom and refresh included. This sample already exist in C++ or javascript, but I need an equivalent in C#.


    Thursday, March 13, 2014 10:41 AM