locked
ZoomToFactor() is getting killed, but ChangeView() doesn't work RRS feed

  • Question

  • VS2013 keeps saying ZoomToFactor() is obsolete and to use ChangeView. But ChangeView doesn't work.

    I just want to initialize the scrollviewer to a predetermined zoomfactor.  Can't get ChangeView() to work at all.  What is the appropriate code am I suppose to use so my app will keep working after 8.1?

    Sunday, December 15, 2013 5:28 PM

Answers

  • Hi ChemCat,

    Currently there is no way to set zoonfactor but by coding. As I told you have to wait everything ready then you can apply the ChangeView().

    I figured out a solution and I think it may help you, after the scrollviewer is ready, I wait for some seconds until the items in scrollviewer are ready, and then execute the ChangeView()

            private void SV2_Loaded(object sender, RoutedEventArgs e)
            {
                TimeSpan period = TimeSpan.FromMilliseconds(100);
    
                Windows.System.Threading.ThreadPoolTimer.CreateTimer(async (source) =>
                {
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        Debug.WriteLine("SV2 inited");
                        this.SV2.ChangeView(280.0, 280.0, 1);
                    });
                }
                , period);
            }

    Hope this will help you.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, December 19, 2013 5:15 AM
    Moderator

All replies

  • Hi ChemCat,

    May I know if ChangeView() works fine if you fire this method in a button click event.

    As far as I know if your ScrollViewer is loaded but the item in ScrollViewer is not finish rendered, the ChangeView() will do nothing, the only chance is to wait everything is ready, or you can assign a width/height for the item.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, December 16, 2013 8:37 AM
    Moderator
  • If changeview will only fire due to button click, what other command can I use to initialize zoomfactor?  working on a LOB app for my company and I'd rather not have the app break when 8.2 comes out.  And why is zoomtofactor getting killed?
    Monday, December 16, 2013 4:56 PM
  • Hi ChemCat,

    The button click is just a example, not mean the changeview will only fire with that. What I mean is you have to wait everything is ready, then use the ChangeView().

    And actually this issue has been raised in the forum before, the solution is to set the height and width instead of using the system calculation one, however it seems not to be a convincing reason. Currently there is no prefect solution and I will continue work on this to see if we can find one.

    Why ZoomToFactor getting killed? I don't know, integrate three different methods might be easy to use, perhaps.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Tuesday, December 17, 2013 1:13 AM
    Moderator
  • Ok, I don't care how I get there.  How would I go about setting an initial zoomfactor value?  I don't see such an option in xaml.  Thank you for your help by the way.  You guys are the best.
    Tuesday, December 17, 2013 9:40 PM
  • Hi ChemCat,

    Currently there is no way to set zoonfactor but by coding. As I told you have to wait everything ready then you can apply the ChangeView().

    I figured out a solution and I think it may help you, after the scrollviewer is ready, I wait for some seconds until the items in scrollviewer are ready, and then execute the ChangeView()

            private void SV2_Loaded(object sender, RoutedEventArgs e)
            {
                TimeSpan period = TimeSpan.FromMilliseconds(100);
    
                Windows.System.Threading.ThreadPoolTimer.CreateTimer(async (source) =>
                {
                    await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        Debug.WriteLine("SV2 inited");
                        this.SV2.ChangeView(280.0, 280.0, 1);
                    });
                }
                , period);
            }

    Hope this will help you.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, December 19, 2013 5:15 AM
    Moderator
  • It works.  Thank you.  Now, I can sleep easy.  I don't want people in the company calling me bitching about the app not working after an 8.2 or 9 update.  The project started for personal use only.  Popular demand made me share it.

    Friday, December 20, 2013 1:50 PM