Animate thumb of UWP SliderHow can I update the current line in a C# Windows Console App?UWP : How to Set Mindate and MaxDate for CalendarDatePicker Control in xamlHow restart the animation in UWP using Visible property?C# UWP Animate Canvas positionXAML UWP - How to use animations in RenderTransform on elements in a ItemsControl (Data Binding)How do I listen to UWP Xaml Slider manipulation start/end events?UWP Animating list item moveUWP Touch Volume ControlSlider with custom ticks (labels and pace)UWP Animation resets to From state

Bone Decomposition

Can you perfectly wrap a cube with this blocky shape?

What advantages do focused Arrows of Slaying have over more generic ones?

Why doesn't philosophy have higher standards for its arguments?

Manually select/unselect lines before forwarding to stdout

What powers the air required for pneumatic brakes in aircraft?

If I stood next to a piece of metal heated to a million degrees, but in a perfect vacuum, would I feel hot?

Snaking a clogged tub drain

How fast does a character need to move to be effectively invisible?

Finding the package which provides a given command

Did 007 exist before James Bond?

Why don't commercial aircraft adopt a slightly more seaplane-like design to allow safer ditching in case of emergency?

FPGA CPU's, how to find the max speed?

What details should I consider before agreeing for part of my salary to be 'retained' by employer?

Data Filters and Measures Error for Unique Opens

Accidentally deleted python and yum is not working in centos7

Cine footage fron Saturn V launch's

Returning strings showing all vertices from all polygons in shapefile using ArcPy?

What is the word for "event executor"?

Alphanumeric Line and Curve Counting

Can a dragon's breath weapon pass through Leomund's Tiny Hut?

What happens on Day 6?

Why do candidates not quit if they no longer have a realistic chance to win in the 2020 US presidents election

Is it OK to use personal email ID for faculty job applications or should we use (current) institute's ID



Animate thumb of UWP Slider


How can I update the current line in a C# Windows Console App?UWP : How to Set Mindate and MaxDate for CalendarDatePicker Control in xamlHow restart the animation in UWP using Visible property?C# UWP Animate Canvas positionXAML UWP - How to use animations in RenderTransform on elements in a ItemsControl (Data Binding)How do I listen to UWP Xaml Slider manipulation start/end events?UWP Animating list item moveUWP Touch Volume ControlSlider with custom ticks (labels and pace)UWP Animation resets to From state






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am using the Slider XAML control in my UWP app. Whenever we tap on the slider and change its value, I want the slider thumb to simply show a translation animation while moving from the old position to the new position. How can this be achieved?










share|improve this question




























    0















    I am using the Slider XAML control in my UWP app. Whenever we tap on the slider and change its value, I want the slider thumb to simply show a translation animation while moving from the old position to the new position. How can this be achieved?










    share|improve this question
























      0












      0








      0








      I am using the Slider XAML control in my UWP app. Whenever we tap on the slider and change its value, I want the slider thumb to simply show a translation animation while moving from the old position to the new position. How can this be achieved?










      share|improve this question














      I am using the Slider XAML control in my UWP app. Whenever we tap on the slider and change its value, I want the slider thumb to simply show a translation animation while moving from the old position to the new position. How can this be achieved?







      c# windows uwp win-universal-app uwp-xaml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 8:20









      PraveenPraveen

      244 bronze badges




      244 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          2














          You can use a property to get the last value and play an animation to set the value from the last vale to current value.



          Adding a Slider in xaml



           <Slider x:Name="Slider" Value="x:Bind Value,Mode=TwoWay"/>


          Adding a DependencyProperty in MainPage.



           public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
          "Value", typeof(double), typeof(MainPage), new PropertyMetadata(default(double), (s
          , e) =>

          ((MainPage) s)._lastValue = (double) e.OldValue;
          ));

          public double Value

          get => (double) GetValue(ValueProperty);
          set => SetValue(ValueProperty, value);


          private double _lastValue;


          The Value can set the _lastValue that can begin the Storyboard



          Adding PointerPressedEvent and PointerReleasedEvent in MainPage code for the Slider will handle it.



           public MainPage()

          InitializeComponent();
          Slider.AddHandler(PointerPressedEvent, new PointerEventHandler(Slider_OnPointerPressed), true);
          Slider.AddHandler(PointerReleasedEvent, new PointerEventHandler(Slider_OnPointerReleased), true);



          I save the ClickPoint in Slider_OnPointerPressed and I compare the current point in Slider_OnPointerReleased. The user may click the Slider that should begin the animation and the user drag the thumb that should not begin the animation.



           private void Slider_OnPointerPressed(object sender, PointerRoutedEventArgs e)

          var slider = (Slider) sender;

          ClickPoint = e.GetCurrentPoint(slider).Position;


          private Point ClickPoint set; get;

          private void Slider_OnPointerReleased(object sender, PointerRoutedEventArgs e)

          var slider = (Slider) sender;

          var point = e.GetCurrentPoint(slider).Position;

          var x = point.X - ClickPoint.X;
          var y = point.Y - ClickPoint.Y;
          var length = x * x + y * y;
          if (length < 10)

          AnimationValue();




          The AnimationValue will begin the animation.



           private void AnimationValue()

          var storyboard = new Storyboard();

          var animation = new DoubleAnimation

          From = _lastValue,
          To = Value,
          Duration = TimeSpan.FromSeconds(2),
          EasingFunction = new CubicEase(),
          EnableDependentAnimation = true
          ;

          Storyboard.SetTarget(animation, Slider);
          Storyboard.SetTargetProperty(animation, "Value");

          storyboard.BeginTime = TimeSpan.Zero;
          storyboard.Children.Add(animation);

          storyboard.Begin();

          _storyboard = storyboard;



          You can custom the Duration and EasingFunction to change the time.



          All code in github



          If you can read Chinese, please read my blog because my English is very poor, I am worried that I can’t tell you exactly what I mean.






          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',
            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%2f55352604%2fanimate-thumb-of-uwp-slider%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









            2














            You can use a property to get the last value and play an animation to set the value from the last vale to current value.



            Adding a Slider in xaml



             <Slider x:Name="Slider" Value="x:Bind Value,Mode=TwoWay"/>


            Adding a DependencyProperty in MainPage.



             public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
            "Value", typeof(double), typeof(MainPage), new PropertyMetadata(default(double), (s
            , e) =>

            ((MainPage) s)._lastValue = (double) e.OldValue;
            ));

            public double Value

            get => (double) GetValue(ValueProperty);
            set => SetValue(ValueProperty, value);


            private double _lastValue;


            The Value can set the _lastValue that can begin the Storyboard



            Adding PointerPressedEvent and PointerReleasedEvent in MainPage code for the Slider will handle it.



             public MainPage()

            InitializeComponent();
            Slider.AddHandler(PointerPressedEvent, new PointerEventHandler(Slider_OnPointerPressed), true);
            Slider.AddHandler(PointerReleasedEvent, new PointerEventHandler(Slider_OnPointerReleased), true);



            I save the ClickPoint in Slider_OnPointerPressed and I compare the current point in Slider_OnPointerReleased. The user may click the Slider that should begin the animation and the user drag the thumb that should not begin the animation.



             private void Slider_OnPointerPressed(object sender, PointerRoutedEventArgs e)

            var slider = (Slider) sender;

            ClickPoint = e.GetCurrentPoint(slider).Position;


            private Point ClickPoint set; get;

            private void Slider_OnPointerReleased(object sender, PointerRoutedEventArgs e)

            var slider = (Slider) sender;

            var point = e.GetCurrentPoint(slider).Position;

            var x = point.X - ClickPoint.X;
            var y = point.Y - ClickPoint.Y;
            var length = x * x + y * y;
            if (length < 10)

            AnimationValue();




            The AnimationValue will begin the animation.



             private void AnimationValue()

            var storyboard = new Storyboard();

            var animation = new DoubleAnimation

            From = _lastValue,
            To = Value,
            Duration = TimeSpan.FromSeconds(2),
            EasingFunction = new CubicEase(),
            EnableDependentAnimation = true
            ;

            Storyboard.SetTarget(animation, Slider);
            Storyboard.SetTargetProperty(animation, "Value");

            storyboard.BeginTime = TimeSpan.Zero;
            storyboard.Children.Add(animation);

            storyboard.Begin();

            _storyboard = storyboard;



            You can custom the Duration and EasingFunction to change the time.



            All code in github



            If you can read Chinese, please read my blog because my English is very poor, I am worried that I can’t tell you exactly what I mean.






            share|improve this answer





























              2














              You can use a property to get the last value and play an animation to set the value from the last vale to current value.



              Adding a Slider in xaml



               <Slider x:Name="Slider" Value="x:Bind Value,Mode=TwoWay"/>


              Adding a DependencyProperty in MainPage.



               public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
              "Value", typeof(double), typeof(MainPage), new PropertyMetadata(default(double), (s
              , e) =>

              ((MainPage) s)._lastValue = (double) e.OldValue;
              ));

              public double Value

              get => (double) GetValue(ValueProperty);
              set => SetValue(ValueProperty, value);


              private double _lastValue;


              The Value can set the _lastValue that can begin the Storyboard



              Adding PointerPressedEvent and PointerReleasedEvent in MainPage code for the Slider will handle it.



               public MainPage()

              InitializeComponent();
              Slider.AddHandler(PointerPressedEvent, new PointerEventHandler(Slider_OnPointerPressed), true);
              Slider.AddHandler(PointerReleasedEvent, new PointerEventHandler(Slider_OnPointerReleased), true);



              I save the ClickPoint in Slider_OnPointerPressed and I compare the current point in Slider_OnPointerReleased. The user may click the Slider that should begin the animation and the user drag the thumb that should not begin the animation.



               private void Slider_OnPointerPressed(object sender, PointerRoutedEventArgs e)

              var slider = (Slider) sender;

              ClickPoint = e.GetCurrentPoint(slider).Position;


              private Point ClickPoint set; get;

              private void Slider_OnPointerReleased(object sender, PointerRoutedEventArgs e)

              var slider = (Slider) sender;

              var point = e.GetCurrentPoint(slider).Position;

              var x = point.X - ClickPoint.X;
              var y = point.Y - ClickPoint.Y;
              var length = x * x + y * y;
              if (length < 10)

              AnimationValue();




              The AnimationValue will begin the animation.



               private void AnimationValue()

              var storyboard = new Storyboard();

              var animation = new DoubleAnimation

              From = _lastValue,
              To = Value,
              Duration = TimeSpan.FromSeconds(2),
              EasingFunction = new CubicEase(),
              EnableDependentAnimation = true
              ;

              Storyboard.SetTarget(animation, Slider);
              Storyboard.SetTargetProperty(animation, "Value");

              storyboard.BeginTime = TimeSpan.Zero;
              storyboard.Children.Add(animation);

              storyboard.Begin();

              _storyboard = storyboard;



              You can custom the Duration and EasingFunction to change the time.



              All code in github



              If you can read Chinese, please read my blog because my English is very poor, I am worried that I can’t tell you exactly what I mean.






              share|improve this answer



























                2












                2








                2







                You can use a property to get the last value and play an animation to set the value from the last vale to current value.



                Adding a Slider in xaml



                 <Slider x:Name="Slider" Value="x:Bind Value,Mode=TwoWay"/>


                Adding a DependencyProperty in MainPage.



                 public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
                "Value", typeof(double), typeof(MainPage), new PropertyMetadata(default(double), (s
                , e) =>

                ((MainPage) s)._lastValue = (double) e.OldValue;
                ));

                public double Value

                get => (double) GetValue(ValueProperty);
                set => SetValue(ValueProperty, value);


                private double _lastValue;


                The Value can set the _lastValue that can begin the Storyboard



                Adding PointerPressedEvent and PointerReleasedEvent in MainPage code for the Slider will handle it.



                 public MainPage()

                InitializeComponent();
                Slider.AddHandler(PointerPressedEvent, new PointerEventHandler(Slider_OnPointerPressed), true);
                Slider.AddHandler(PointerReleasedEvent, new PointerEventHandler(Slider_OnPointerReleased), true);



                I save the ClickPoint in Slider_OnPointerPressed and I compare the current point in Slider_OnPointerReleased. The user may click the Slider that should begin the animation and the user drag the thumb that should not begin the animation.



                 private void Slider_OnPointerPressed(object sender, PointerRoutedEventArgs e)

                var slider = (Slider) sender;

                ClickPoint = e.GetCurrentPoint(slider).Position;


                private Point ClickPoint set; get;

                private void Slider_OnPointerReleased(object sender, PointerRoutedEventArgs e)

                var slider = (Slider) sender;

                var point = e.GetCurrentPoint(slider).Position;

                var x = point.X - ClickPoint.X;
                var y = point.Y - ClickPoint.Y;
                var length = x * x + y * y;
                if (length < 10)

                AnimationValue();




                The AnimationValue will begin the animation.



                 private void AnimationValue()

                var storyboard = new Storyboard();

                var animation = new DoubleAnimation

                From = _lastValue,
                To = Value,
                Duration = TimeSpan.FromSeconds(2),
                EasingFunction = new CubicEase(),
                EnableDependentAnimation = true
                ;

                Storyboard.SetTarget(animation, Slider);
                Storyboard.SetTargetProperty(animation, "Value");

                storyboard.BeginTime = TimeSpan.Zero;
                storyboard.Children.Add(animation);

                storyboard.Begin();

                _storyboard = storyboard;



                You can custom the Duration and EasingFunction to change the time.



                All code in github



                If you can read Chinese, please read my blog because my English is very poor, I am worried that I can’t tell you exactly what I mean.






                share|improve this answer















                You can use a property to get the last value and play an animation to set the value from the last vale to current value.



                Adding a Slider in xaml



                 <Slider x:Name="Slider" Value="x:Bind Value,Mode=TwoWay"/>


                Adding a DependencyProperty in MainPage.



                 public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
                "Value", typeof(double), typeof(MainPage), new PropertyMetadata(default(double), (s
                , e) =>

                ((MainPage) s)._lastValue = (double) e.OldValue;
                ));

                public double Value

                get => (double) GetValue(ValueProperty);
                set => SetValue(ValueProperty, value);


                private double _lastValue;


                The Value can set the _lastValue that can begin the Storyboard



                Adding PointerPressedEvent and PointerReleasedEvent in MainPage code for the Slider will handle it.



                 public MainPage()

                InitializeComponent();
                Slider.AddHandler(PointerPressedEvent, new PointerEventHandler(Slider_OnPointerPressed), true);
                Slider.AddHandler(PointerReleasedEvent, new PointerEventHandler(Slider_OnPointerReleased), true);



                I save the ClickPoint in Slider_OnPointerPressed and I compare the current point in Slider_OnPointerReleased. The user may click the Slider that should begin the animation and the user drag the thumb that should not begin the animation.



                 private void Slider_OnPointerPressed(object sender, PointerRoutedEventArgs e)

                var slider = (Slider) sender;

                ClickPoint = e.GetCurrentPoint(slider).Position;


                private Point ClickPoint set; get;

                private void Slider_OnPointerReleased(object sender, PointerRoutedEventArgs e)

                var slider = (Slider) sender;

                var point = e.GetCurrentPoint(slider).Position;

                var x = point.X - ClickPoint.X;
                var y = point.Y - ClickPoint.Y;
                var length = x * x + y * y;
                if (length < 10)

                AnimationValue();




                The AnimationValue will begin the animation.



                 private void AnimationValue()

                var storyboard = new Storyboard();

                var animation = new DoubleAnimation

                From = _lastValue,
                To = Value,
                Duration = TimeSpan.FromSeconds(2),
                EasingFunction = new CubicEase(),
                EnableDependentAnimation = true
                ;

                Storyboard.SetTarget(animation, Slider);
                Storyboard.SetTargetProperty(animation, "Value");

                storyboard.BeginTime = TimeSpan.Zero;
                storyboard.Children.Add(animation);

                storyboard.Begin();

                _storyboard = storyboard;



                You can custom the Duration and EasingFunction to change the time.



                All code in github



                If you can read Chinese, please read my blog because my English is very poor, I am worried that I can’t tell you exactly what I mean.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 27 at 3:00

























                answered Mar 27 at 2:05









                lindexilindexi

                2,7271 gold badge8 silver badges43 bronze badges




                2,7271 gold badge8 silver badges43 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    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%2f55352604%2fanimate-thumb-of-uwp-slider%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현