UWP Page Transition, Change Animation Direction












0















I have UWP app that I use Frame.Navigate() method a lot. By default it seems to be performing transitions with an animation that makes next screen appear sliding from bottom. However, for my case it makes more sense if next screen comes from right or left.



So, to change this default behaviour, I used the following code from this MSDN document:



// Navigate to the right, ie. from LeftPage to RightPage
myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromRight } );

// Navigate to the left, ie. from RightPage to LeftPage
myFrame.Navigate(typeof(LeftPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromLeft } );


but I get this error:




Cannot initialize type 'SlideNavigationTransitionInfo' with a
collection initializer because it does not implement
'System.Collections.IEnumerable'




Changing code like this



myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight } );


causes app to crash by Invalid cast exception.



This was an old app that I'm updating so I suspected that might cause the issue and I updated the target version. Now targetting section looks like:



Target version: 1809 (10.0; Build 17763);



Min version : (10.0; 10240)



but still, problem persists.
Any idea how to solve this?










share|improve this question























  • What is the exact error of Invalid cast exception? From which type to which type?

    – kennyzx
    Nov 13 '18 at 15:25











  • It says Unable to cast object of type 'Windows.UI.Xaml.Media.Animation.SlideNavigationTransitionInfo' to type 'Windows.UI.Xaml.Media.Animation.ISlideNavigationTransitionInfo2

    – t.m.
    Nov 13 '18 at 15:49


















0















I have UWP app that I use Frame.Navigate() method a lot. By default it seems to be performing transitions with an animation that makes next screen appear sliding from bottom. However, for my case it makes more sense if next screen comes from right or left.



So, to change this default behaviour, I used the following code from this MSDN document:



// Navigate to the right, ie. from LeftPage to RightPage
myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromRight } );

// Navigate to the left, ie. from RightPage to LeftPage
myFrame.Navigate(typeof(LeftPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromLeft } );


but I get this error:




Cannot initialize type 'SlideNavigationTransitionInfo' with a
collection initializer because it does not implement
'System.Collections.IEnumerable'




Changing code like this



myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight } );


causes app to crash by Invalid cast exception.



This was an old app that I'm updating so I suspected that might cause the issue and I updated the target version. Now targetting section looks like:



Target version: 1809 (10.0; Build 17763);



Min version : (10.0; 10240)



but still, problem persists.
Any idea how to solve this?










share|improve this question























  • What is the exact error of Invalid cast exception? From which type to which type?

    – kennyzx
    Nov 13 '18 at 15:25











  • It says Unable to cast object of type 'Windows.UI.Xaml.Media.Animation.SlideNavigationTransitionInfo' to type 'Windows.UI.Xaml.Media.Animation.ISlideNavigationTransitionInfo2

    – t.m.
    Nov 13 '18 at 15:49
















0












0








0








I have UWP app that I use Frame.Navigate() method a lot. By default it seems to be performing transitions with an animation that makes next screen appear sliding from bottom. However, for my case it makes more sense if next screen comes from right or left.



So, to change this default behaviour, I used the following code from this MSDN document:



// Navigate to the right, ie. from LeftPage to RightPage
myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromRight } );

// Navigate to the left, ie. from RightPage to LeftPage
myFrame.Navigate(typeof(LeftPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromLeft } );


but I get this error:




Cannot initialize type 'SlideNavigationTransitionInfo' with a
collection initializer because it does not implement
'System.Collections.IEnumerable'




Changing code like this



myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight } );


causes app to crash by Invalid cast exception.



This was an old app that I'm updating so I suspected that might cause the issue and I updated the target version. Now targetting section looks like:



Target version: 1809 (10.0; Build 17763);



Min version : (10.0; 10240)



but still, problem persists.
Any idea how to solve this?










share|improve this question














I have UWP app that I use Frame.Navigate() method a lot. By default it seems to be performing transitions with an animation that makes next screen appear sliding from bottom. However, for my case it makes more sense if next screen comes from right or left.



So, to change this default behaviour, I used the following code from this MSDN document:



// Navigate to the right, ie. from LeftPage to RightPage
myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromRight } );

// Navigate to the left, ie. from RightPage to LeftPage
myFrame.Navigate(typeof(LeftPage), null, new SlideNavigationTransitionInfo() { SlideNavigationTransitionEffect.FromLeft } );


but I get this error:




Cannot initialize type 'SlideNavigationTransitionInfo' with a
collection initializer because it does not implement
'System.Collections.IEnumerable'




Changing code like this



myFrame.Navigate(typeof(RightPage), null, new SlideNavigationTransitionInfo() { Effect = SlideNavigationTransitionEffect.FromRight } );


causes app to crash by Invalid cast exception.



This was an old app that I'm updating so I suspected that might cause the issue and I updated the target version. Now targetting section looks like:



Target version: 1809 (10.0; Build 17763);



Min version : (10.0; 10240)



but still, problem persists.
Any idea how to solve this?







c# uwp win-universal-app






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 11:55









t.m.t.m.

695715




695715













  • What is the exact error of Invalid cast exception? From which type to which type?

    – kennyzx
    Nov 13 '18 at 15:25











  • It says Unable to cast object of type 'Windows.UI.Xaml.Media.Animation.SlideNavigationTransitionInfo' to type 'Windows.UI.Xaml.Media.Animation.ISlideNavigationTransitionInfo2

    – t.m.
    Nov 13 '18 at 15:49





















  • What is the exact error of Invalid cast exception? From which type to which type?

    – kennyzx
    Nov 13 '18 at 15:25











  • It says Unable to cast object of type 'Windows.UI.Xaml.Media.Animation.SlideNavigationTransitionInfo' to type 'Windows.UI.Xaml.Media.Animation.ISlideNavigationTransitionInfo2

    – t.m.
    Nov 13 '18 at 15:49



















What is the exact error of Invalid cast exception? From which type to which type?

– kennyzx
Nov 13 '18 at 15:25





What is the exact error of Invalid cast exception? From which type to which type?

– kennyzx
Nov 13 '18 at 15:25













It says Unable to cast object of type 'Windows.UI.Xaml.Media.Animation.SlideNavigationTransitionInfo' to type 'Windows.UI.Xaml.Media.Animation.ISlideNavigationTransitionInfo2

– t.m.
Nov 13 '18 at 15:49







It says Unable to cast object of type 'Windows.UI.Xaml.Media.Animation.SlideNavigationTransitionInfo' to type 'Windows.UI.Xaml.Media.Animation.ISlideNavigationTransitionInfo2

– t.m.
Nov 13 '18 at 15:49














2 Answers
2






active

oldest

votes


















1














If you prefer , You can simply use XAML page transitions, its also compatible with min version 10240:
just put below lines in your RightPage or LeftPage XAML source.



<Page.Transitions>
<TransitionCollection>
<EdgeUIThemeTransition Edge="Left">
</EdgeUIThemeTransition>
</TransitionCollection>
</Page.Transitions>





share|improve this answer































    3














    The first syntax error is quite self-explanatory; while the InvalidCastException seems to be caused by the fact that you are running you code on an OS with a version lower than 1809.



    SlideNavigationTransitionEffect Enum was added in 1809. You can compile your code successfully because you have installed the SDK for 1809, but at runtime, if you don’t check beforehand, this code fails if runtime doesn’t support it.



    //remove this from your code and it should be running well
    Effect = SlideNavigationTransitionEffect.FromRight


    In this case, you can set the Min version as 1809, to enforce this app can only be installed on 1809 or higher. Or you can write version adaptive code to check the OS support for the API, in this way, you can keep you Min version as low as desired to target a wider range of devices.






    share|improve this answer


























    • This seems to be the issue.

      – t.m.
      Nov 14 '18 at 8:11






    • 1





      Thanks for such a comprehensive answer +1. It also helped me to solve my other issues related to this OS version problem. However other solution is simple and eliminates backward compatability issue, I think it is better for googlers.

      – t.m.
      Nov 14 '18 at 16:14











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280521%2fuwp-page-transition-change-animation-direction%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    If you prefer , You can simply use XAML page transitions, its also compatible with min version 10240:
    just put below lines in your RightPage or LeftPage XAML source.



    <Page.Transitions>
    <TransitionCollection>
    <EdgeUIThemeTransition Edge="Left">
    </EdgeUIThemeTransition>
    </TransitionCollection>
    </Page.Transitions>





    share|improve this answer




























      1














      If you prefer , You can simply use XAML page transitions, its also compatible with min version 10240:
      just put below lines in your RightPage or LeftPage XAML source.



      <Page.Transitions>
      <TransitionCollection>
      <EdgeUIThemeTransition Edge="Left">
      </EdgeUIThemeTransition>
      </TransitionCollection>
      </Page.Transitions>





      share|improve this answer


























        1












        1








        1







        If you prefer , You can simply use XAML page transitions, its also compatible with min version 10240:
        just put below lines in your RightPage or LeftPage XAML source.



        <Page.Transitions>
        <TransitionCollection>
        <EdgeUIThemeTransition Edge="Left">
        </EdgeUIThemeTransition>
        </TransitionCollection>
        </Page.Transitions>





        share|improve this answer













        If you prefer , You can simply use XAML page transitions, its also compatible with min version 10240:
        just put below lines in your RightPage or LeftPage XAML source.



        <Page.Transitions>
        <TransitionCollection>
        <EdgeUIThemeTransition Edge="Left">
        </EdgeUIThemeTransition>
        </TransitionCollection>
        </Page.Transitions>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 6:39









        MKHMKH

        232310




        232310

























            3














            The first syntax error is quite self-explanatory; while the InvalidCastException seems to be caused by the fact that you are running you code on an OS with a version lower than 1809.



            SlideNavigationTransitionEffect Enum was added in 1809. You can compile your code successfully because you have installed the SDK for 1809, but at runtime, if you don’t check beforehand, this code fails if runtime doesn’t support it.



            //remove this from your code and it should be running well
            Effect = SlideNavigationTransitionEffect.FromRight


            In this case, you can set the Min version as 1809, to enforce this app can only be installed on 1809 or higher. Or you can write version adaptive code to check the OS support for the API, in this way, you can keep you Min version as low as desired to target a wider range of devices.






            share|improve this answer


























            • This seems to be the issue.

              – t.m.
              Nov 14 '18 at 8:11






            • 1





              Thanks for such a comprehensive answer +1. It also helped me to solve my other issues related to this OS version problem. However other solution is simple and eliminates backward compatability issue, I think it is better for googlers.

              – t.m.
              Nov 14 '18 at 16:14
















            3














            The first syntax error is quite self-explanatory; while the InvalidCastException seems to be caused by the fact that you are running you code on an OS with a version lower than 1809.



            SlideNavigationTransitionEffect Enum was added in 1809. You can compile your code successfully because you have installed the SDK for 1809, but at runtime, if you don’t check beforehand, this code fails if runtime doesn’t support it.



            //remove this from your code and it should be running well
            Effect = SlideNavigationTransitionEffect.FromRight


            In this case, you can set the Min version as 1809, to enforce this app can only be installed on 1809 or higher. Or you can write version adaptive code to check the OS support for the API, in this way, you can keep you Min version as low as desired to target a wider range of devices.






            share|improve this answer


























            • This seems to be the issue.

              – t.m.
              Nov 14 '18 at 8:11






            • 1





              Thanks for such a comprehensive answer +1. It also helped me to solve my other issues related to this OS version problem. However other solution is simple and eliminates backward compatability issue, I think it is better for googlers.

              – t.m.
              Nov 14 '18 at 16:14














            3












            3








            3







            The first syntax error is quite self-explanatory; while the InvalidCastException seems to be caused by the fact that you are running you code on an OS with a version lower than 1809.



            SlideNavigationTransitionEffect Enum was added in 1809. You can compile your code successfully because you have installed the SDK for 1809, but at runtime, if you don’t check beforehand, this code fails if runtime doesn’t support it.



            //remove this from your code and it should be running well
            Effect = SlideNavigationTransitionEffect.FromRight


            In this case, you can set the Min version as 1809, to enforce this app can only be installed on 1809 or higher. Or you can write version adaptive code to check the OS support for the API, in this way, you can keep you Min version as low as desired to target a wider range of devices.






            share|improve this answer















            The first syntax error is quite self-explanatory; while the InvalidCastException seems to be caused by the fact that you are running you code on an OS with a version lower than 1809.



            SlideNavigationTransitionEffect Enum was added in 1809. You can compile your code successfully because you have installed the SDK for 1809, but at runtime, if you don’t check beforehand, this code fails if runtime doesn’t support it.



            //remove this from your code and it should be running well
            Effect = SlideNavigationTransitionEffect.FromRight


            In this case, you can set the Min version as 1809, to enforce this app can only be installed on 1809 or higher. Or you can write version adaptive code to check the OS support for the API, in this way, you can keep you Min version as low as desired to target a wider range of devices.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 14 '18 at 4:39

























            answered Nov 14 '18 at 4:26









            kennyzxkennyzx

            10k42264




            10k42264













            • This seems to be the issue.

              – t.m.
              Nov 14 '18 at 8:11






            • 1





              Thanks for such a comprehensive answer +1. It also helped me to solve my other issues related to this OS version problem. However other solution is simple and eliminates backward compatability issue, I think it is better for googlers.

              – t.m.
              Nov 14 '18 at 16:14



















            • This seems to be the issue.

              – t.m.
              Nov 14 '18 at 8:11






            • 1





              Thanks for such a comprehensive answer +1. It also helped me to solve my other issues related to this OS version problem. However other solution is simple and eliminates backward compatability issue, I think it is better for googlers.

              – t.m.
              Nov 14 '18 at 16:14

















            This seems to be the issue.

            – t.m.
            Nov 14 '18 at 8:11





            This seems to be the issue.

            – t.m.
            Nov 14 '18 at 8:11




            1




            1





            Thanks for such a comprehensive answer +1. It also helped me to solve my other issues related to this OS version problem. However other solution is simple and eliminates backward compatability issue, I think it is better for googlers.

            – t.m.
            Nov 14 '18 at 16:14





            Thanks for such a comprehensive answer +1. It also helped me to solve my other issues related to this OS version problem. However other solution is simple and eliminates backward compatability issue, I think it is better for googlers.

            – t.m.
            Nov 14 '18 at 16:14


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280521%2fuwp-page-transition-change-animation-direction%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Full-time equivalent

            さくらももこ

            13 indicted, 8 arrested in Calif. drug cartel investigation