Slider position should be same after reopening the slider

2 posts, 0 answers
  1. Vivek
    Vivek avatar
    15 posts
    Member since:
    Jun 2011

    Posted 01 Jul 2011 Link to this post

    Hi Team,

     I did the slider left right zoom in ,zoom out But now i am facing another problem, While clicking the slider button the slider is doing zoom in zoom out but when i close the slider and open once again then again the slider is open from the start , The slider should be start from the previous place where i left the slider and close it.

    I want the solution for this how i will open the slider again for the same position where i left the slider .

    Please help me
    private void Zoom_slider_Click(object sender, RoutedEventArgs e)
                RadWindow Zoom_slider_window = new RadWindow();
                Zoom_slider_window.Header = "Zoom Slider";
                Zoom_slider_window.Height = 100;
                Zoom_slider_window.Width = 300;
                Zoom_slider_window.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterOwner;
                Zoom_slider_window.ResizeMode = ResizeMode.NoResize;         
                //Now add a slider to window
                Zoomslider = new RadSlider();          
                Zoomslider.VerticalAlignment = System.Windows.VerticalAlignment.Center;         
                Zoomslider.TickPlacement = TickPlacement.Both;
                Zoomslider.TickFrequency = 2;      
                Zoomslider.HandlesVisibility = System.Windows.Visibility.Visible;
                Zoom_slider_window.Content = Zoomslider;
                Zoomslider.Maximum = 10;
                Zoomslider.Minimum = 1;
                Zoomslider.SmallChange = 0.3;
                if (Zoomslider.Value != null)
                    Zoomslider.SelectionStart = oldZoomValue;
                Zoomslider.Value = 1;
                //Event handling                    
                Zoomslider.ValueChanged+=new RoutedPropertyChangedEventHandler<double>(Zoomslider_ValueChanged);
            private static double oldZoomValue=0;
            private void Zoomslider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
                if (Zoomslider.Value < oldZoomValue)
                    if (Zoomslider.Value > Zoomslider.Minimum)
                oldZoomValue = Zoomslider.Value;
  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 05 Jul 2011 Link to this post

    Hi Vivek,

    The RadWindow re-loads its content every time it has been clicked or has been shown. So if you place a new RadSlider in it the RadSlider will also be reloaded every time and its ValueChanged event will be fired with Value=0.
    Could you please check this out by using a Debug breakpoint in the ValueChanged event. However, the solution you have made is more like a winforms than a Silverlight one. In Silverlight, you can take a full advantage of using ViewModels (MVVM design pattern) bound to your controls. These ViewModels could have properties that are two-way bound and will reflect the changes that you make in the UI.Could this fit in your case ?
    Furthermore, you can examine this demos showing our new PersistenceFramework  ( which is part of Q2 2011 Beta Release) that could be used for saving the current state of a RadControl.
    Please let us know if you need further assistance.

    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top