Animating RadialGauge











up vote
1
down vote

favorite












I'm new to animations, and I would like to animante RadialGauge values changes from x to y, in order make the transitions smoother.



For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.



How can I achieve this?



NOTICE: I'm using MVVM and I set the Value propery via Binding. I hope there's a way to do it without adding code-behind (XAML only, preferably).



Thanks in advance!



I'm trying with Implicit Animations, but I don't understand how they work to animate changes in a property. The code that I've tried is this:



<controls:RadialGauge Value="{Binding Status.Speed, Converter={StaticResource Speed}}">
<animations:Implicit.Animations>
<animations:ScalarAnimation ImplicitTarget="Value" Duration="0:0:0.3" />
</animations:Implicit.Animations>
</controls:RadialGauge>









share|improve this question
























  • did you try Implicit Animations? docs.microsoft.com/en-us/windows/communitytoolkit/animations/…
    – Muzib
    Nov 10 at 12:30










  • @Muzib I have investigated about the topic, but I don't know how to achieve it. Please, check the updated question to see the code I've tried.
    – SuperJMN
    Nov 10 at 20:38

















up vote
1
down vote

favorite












I'm new to animations, and I would like to animante RadialGauge values changes from x to y, in order make the transitions smoother.



For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.



How can I achieve this?



NOTICE: I'm using MVVM and I set the Value propery via Binding. I hope there's a way to do it without adding code-behind (XAML only, preferably).



Thanks in advance!



I'm trying with Implicit Animations, but I don't understand how they work to animate changes in a property. The code that I've tried is this:



<controls:RadialGauge Value="{Binding Status.Speed, Converter={StaticResource Speed}}">
<animations:Implicit.Animations>
<animations:ScalarAnimation ImplicitTarget="Value" Duration="0:0:0.3" />
</animations:Implicit.Animations>
</controls:RadialGauge>









share|improve this question
























  • did you try Implicit Animations? docs.microsoft.com/en-us/windows/communitytoolkit/animations/…
    – Muzib
    Nov 10 at 12:30










  • @Muzib I have investigated about the topic, but I don't know how to achieve it. Please, check the updated question to see the code I've tried.
    – SuperJMN
    Nov 10 at 20:38















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm new to animations, and I would like to animante RadialGauge values changes from x to y, in order make the transitions smoother.



For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.



How can I achieve this?



NOTICE: I'm using MVVM and I set the Value propery via Binding. I hope there's a way to do it without adding code-behind (XAML only, preferably).



Thanks in advance!



I'm trying with Implicit Animations, but I don't understand how they work to animate changes in a property. The code that I've tried is this:



<controls:RadialGauge Value="{Binding Status.Speed, Converter={StaticResource Speed}}">
<animations:Implicit.Animations>
<animations:ScalarAnimation ImplicitTarget="Value" Duration="0:0:0.3" />
</animations:Implicit.Animations>
</controls:RadialGauge>









share|improve this question















I'm new to animations, and I would like to animante RadialGauge values changes from x to y, in order make the transitions smoother.



For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.



How can I achieve this?



NOTICE: I'm using MVVM and I set the Value propery via Binding. I hope there's a way to do it without adding code-behind (XAML only, preferably).



Thanks in advance!



I'm trying with Implicit Animations, but I don't understand how they work to animate changes in a property. The code that I've tried is this:



<controls:RadialGauge Value="{Binding Status.Speed, Converter={StaticResource Speed}}">
<animations:Implicit.Animations>
<animations:ScalarAnimation ImplicitTarget="Value" Duration="0:0:0.3" />
</animations:Implicit.Animations>
</controls:RadialGauge>






uwp windows-community-toolkit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 20:40

























asked Nov 10 at 0:34









SuperJMN

3,12833177




3,12833177












  • did you try Implicit Animations? docs.microsoft.com/en-us/windows/communitytoolkit/animations/…
    – Muzib
    Nov 10 at 12:30










  • @Muzib I have investigated about the topic, but I don't know how to achieve it. Please, check the updated question to see the code I've tried.
    – SuperJMN
    Nov 10 at 20:38




















  • did you try Implicit Animations? docs.microsoft.com/en-us/windows/communitytoolkit/animations/…
    – Muzib
    Nov 10 at 12:30










  • @Muzib I have investigated about the topic, but I don't know how to achieve it. Please, check the updated question to see the code I've tried.
    – SuperJMN
    Nov 10 at 20:38


















did you try Implicit Animations? docs.microsoft.com/en-us/windows/communitytoolkit/animations/…
– Muzib
Nov 10 at 12:30




did you try Implicit Animations? docs.microsoft.com/en-us/windows/communitytoolkit/animations/…
– Muzib
Nov 10 at 12:30












@Muzib I have investigated about the topic, but I don't know how to achieve it. Please, check the updated question to see the code I've tried.
– SuperJMN
Nov 10 at 20:38






@Muzib I have investigated about the topic, but I don't know how to achieve it. Please, check the updated question to see the code I've tried.
– SuperJMN
Nov 10 at 20:38














1 Answer
1






active

oldest

votes

















up vote
0
down vote














For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.




You could use a simple DoubleAnimation to achieve your target like the following:



<Page.Resources>
<Storyboard x:Name="storyboard" >
<DoubleAnimation Storyboard.TargetName="RadialGaugeControl" Storyboard.TargetProperty="Value" From="0" To="100" Duration="0:0:3" EnableDependentAnimation="True"></DoubleAnimation>
</Storyboard>
</Page.Resources>
<Grid>
<controls:RadialGauge x:Name="RadialGaugeControl" Value="70" Minimum="0"
Maximum="180" TickSpacing="20" ScaleWidth="26" Unit="Units" TickBrush="Gainsboro"
ScaleTickBrush="{ThemeResource ApplicationPageBackgroundThemeBrush}"
NeedleWidth="5" TickLength="18" IsInteractive="True">
</controls:RadialGauge>
</Grid>


storyboard.Begin();


By this way, You need to call storyboard.Begin(); in code-hebind at least.




I hope there's a way to do it without adding code-behind (XAML only, preferably).




If you check the RadialGauge control's source code, the value is a dependency property, the needle's angle was changed when the Value is changed. What you said 'without adding code-behind', I assumed that you could use some XAML Behaviors to start the animation, but it has not provide any events for you. I did not think it's simpler than calling storyboard.Begin().



You could choose to change the source code and add an animation for it. When the Value is changed, the OnValueChanged method will be fired, you could start the animation in it. Then, you could compile your custom version for 'Microsoft.Toolkit.Uwp.UI.Controls' and use it in your project. But I did not think it's simpler than just writing one line code storyboard.Begin() in code-behind.






share|improve this answer





















    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',
    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%2f53234973%2fanimating-radialgauge%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote














    For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.




    You could use a simple DoubleAnimation to achieve your target like the following:



    <Page.Resources>
    <Storyboard x:Name="storyboard" >
    <DoubleAnimation Storyboard.TargetName="RadialGaugeControl" Storyboard.TargetProperty="Value" From="0" To="100" Duration="0:0:3" EnableDependentAnimation="True"></DoubleAnimation>
    </Storyboard>
    </Page.Resources>
    <Grid>
    <controls:RadialGauge x:Name="RadialGaugeControl" Value="70" Minimum="0"
    Maximum="180" TickSpacing="20" ScaleWidth="26" Unit="Units" TickBrush="Gainsboro"
    ScaleTickBrush="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    NeedleWidth="5" TickLength="18" IsInteractive="True">
    </controls:RadialGauge>
    </Grid>


    storyboard.Begin();


    By this way, You need to call storyboard.Begin(); in code-hebind at least.




    I hope there's a way to do it without adding code-behind (XAML only, preferably).




    If you check the RadialGauge control's source code, the value is a dependency property, the needle's angle was changed when the Value is changed. What you said 'without adding code-behind', I assumed that you could use some XAML Behaviors to start the animation, but it has not provide any events for you. I did not think it's simpler than calling storyboard.Begin().



    You could choose to change the source code and add an animation for it. When the Value is changed, the OnValueChanged method will be fired, you could start the animation in it. Then, you could compile your custom version for 'Microsoft.Toolkit.Uwp.UI.Controls' and use it in your project. But I did not think it's simpler than just writing one line code storyboard.Begin() in code-behind.






    share|improve this answer

























      up vote
      0
      down vote














      For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.




      You could use a simple DoubleAnimation to achieve your target like the following:



      <Page.Resources>
      <Storyboard x:Name="storyboard" >
      <DoubleAnimation Storyboard.TargetName="RadialGaugeControl" Storyboard.TargetProperty="Value" From="0" To="100" Duration="0:0:3" EnableDependentAnimation="True"></DoubleAnimation>
      </Storyboard>
      </Page.Resources>
      <Grid>
      <controls:RadialGauge x:Name="RadialGaugeControl" Value="70" Minimum="0"
      Maximum="180" TickSpacing="20" ScaleWidth="26" Unit="Units" TickBrush="Gainsboro"
      ScaleTickBrush="{ThemeResource ApplicationPageBackgroundThemeBrush}"
      NeedleWidth="5" TickLength="18" IsInteractive="True">
      </controls:RadialGauge>
      </Grid>


      storyboard.Begin();


      By this way, You need to call storyboard.Begin(); in code-hebind at least.




      I hope there's a way to do it without adding code-behind (XAML only, preferably).




      If you check the RadialGauge control's source code, the value is a dependency property, the needle's angle was changed when the Value is changed. What you said 'without adding code-behind', I assumed that you could use some XAML Behaviors to start the animation, but it has not provide any events for you. I did not think it's simpler than calling storyboard.Begin().



      You could choose to change the source code and add an animation for it. When the Value is changed, the OnValueChanged method will be fired, you could start the animation in it. Then, you could compile your custom version for 'Microsoft.Toolkit.Uwp.UI.Controls' and use it in your project. But I did not think it's simpler than just writing one line code storyboard.Begin() in code-behind.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote










        For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.




        You could use a simple DoubleAnimation to achieve your target like the following:



        <Page.Resources>
        <Storyboard x:Name="storyboard" >
        <DoubleAnimation Storyboard.TargetName="RadialGaugeControl" Storyboard.TargetProperty="Value" From="0" To="100" Duration="0:0:3" EnableDependentAnimation="True"></DoubleAnimation>
        </Storyboard>
        </Page.Resources>
        <Grid>
        <controls:RadialGauge x:Name="RadialGaugeControl" Value="70" Minimum="0"
        Maximum="180" TickSpacing="20" ScaleWidth="26" Unit="Units" TickBrush="Gainsboro"
        ScaleTickBrush="{ThemeResource ApplicationPageBackgroundThemeBrush}"
        NeedleWidth="5" TickLength="18" IsInteractive="True">
        </controls:RadialGauge>
        </Grid>


        storyboard.Begin();


        By this way, You need to call storyboard.Begin(); in code-hebind at least.




        I hope there's a way to do it without adding code-behind (XAML only, preferably).




        If you check the RadialGauge control's source code, the value is a dependency property, the needle's angle was changed when the Value is changed. What you said 'without adding code-behind', I assumed that you could use some XAML Behaviors to start the animation, but it has not provide any events for you. I did not think it's simpler than calling storyboard.Begin().



        You could choose to change the source code and add an animation for it. When the Value is changed, the OnValueChanged method will be fired, you could start the animation in it. Then, you could compile your custom version for 'Microsoft.Toolkit.Uwp.UI.Controls' and use it in your project. But I did not think it's simpler than just writing one line code storyboard.Begin() in code-behind.






        share|improve this answer













        For example, if the Value property changes from 0 to 100, I would like theRadialGauge` to go through all the intermediate values in, for example, 250 ms.




        You could use a simple DoubleAnimation to achieve your target like the following:



        <Page.Resources>
        <Storyboard x:Name="storyboard" >
        <DoubleAnimation Storyboard.TargetName="RadialGaugeControl" Storyboard.TargetProperty="Value" From="0" To="100" Duration="0:0:3" EnableDependentAnimation="True"></DoubleAnimation>
        </Storyboard>
        </Page.Resources>
        <Grid>
        <controls:RadialGauge x:Name="RadialGaugeControl" Value="70" Minimum="0"
        Maximum="180" TickSpacing="20" ScaleWidth="26" Unit="Units" TickBrush="Gainsboro"
        ScaleTickBrush="{ThemeResource ApplicationPageBackgroundThemeBrush}"
        NeedleWidth="5" TickLength="18" IsInteractive="True">
        </controls:RadialGauge>
        </Grid>


        storyboard.Begin();


        By this way, You need to call storyboard.Begin(); in code-hebind at least.




        I hope there's a way to do it without adding code-behind (XAML only, preferably).




        If you check the RadialGauge control's source code, the value is a dependency property, the needle's angle was changed when the Value is changed. What you said 'without adding code-behind', I assumed that you could use some XAML Behaviors to start the animation, but it has not provide any events for you. I did not think it's simpler than calling storyboard.Begin().



        You could choose to change the source code and add an animation for it. When the Value is changed, the OnValueChanged method will be fired, you could start the animation in it. Then, you could compile your custom version for 'Microsoft.Toolkit.Uwp.UI.Controls' and use it in your project. But I did not think it's simpler than just writing one line code storyboard.Begin() in code-behind.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 8:03









        Xavier Xie - MSFT

        4,4411315




        4,4411315






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234973%2fanimating-radialgauge%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

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python