This is a migrated thread and some comments may be shown as answers.

Slider position should be same after reopening the slider

1 Answer 30 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Vivek
Top achievements
Rank 1
Vivek asked on 01 Jul 2011, 10:26 AM

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;         
            Pre_grid.Children.Add(Zoom_slider_window);
            Zoom_slider_window.Show();
  
  
  
            //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)
            {
                ZoomOut();
            }
  
            else
            {
                if (Zoomslider.Value > Zoomslider.Minimum)
                {
  
  
                    ZoomIn();
  
                }
            }
            oldZoomValue = Zoomslider.Value;
        }
e.

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 05 Jul 2011, 08:38 AM
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.

Greetings,
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
Tags
Slider
Asked by
Vivek
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or