Dynamic Maximun and Minimum update not working

11 posts, 0 answers
  1. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 19 Mar 2009 Link to this post

    I have a slider with a certain range. Let's say 5-10. Now, I am dynamically trying to update it to a range which is 2-3. It is not working right. THe new minimum (2) is set correctly, but not the new maximun (3). I figured out that if the new Maximun is less than the previous Minimum I get this issue. Any ideas?

    --t
  2. Bobi
    Admin
    Bobi avatar
    513 posts

    Posted 20 Mar 2009 Link to this post

    Hi Tolga,

    Can you please provide some more information about the problem (some code).
    I set the Minimum and Maximum properties dynamically and the SelectionStart and SelectinEnd properties and it works as expected. 

    All the best,
    Boryana
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 20 Mar 2009 Link to this post

     

    this.xaml_planningarea.Maximum = Convert.ToDouble(dMaxNumberPlanngingArea);

     

     

    this.xaml_planningarea.Minimum = Convert.ToDouble(dMinNumberPlanngingArea);

     

     

    this.xaml_planningarea.SelectionStart = Convert.ToDouble(dMinNumberSelectedPlanngingArea);

     

     

    this.xaml_planningarea.SelectionEnd = Convert.ToDouble(dMaxNumberSelectedPlanngingArea);

     

     

     

    this.xaml_planningarea.UpdateLayout();

    So, this code works as expected for only certain numbers. Again, here is my example. I initially set the maximum and minimum value of the slide to 5 and 10, respectively. So, the minimum is 5 and the maximum is 10.
    The code DOES NOT WORK as expected when I now set the range to 2 and 3, for example. I have discovered, that if the NEW maximum value, in this case 3, is lower than the previous minimum value, in our example 5. Does that make sense?

    To summaries, I start with 5-10 as my range. Setting it to, let's say, 3-7, works, because 7 > 5. But now, when I set it to 2-3, the slider does not update correctly. In this case the slider shows 2-5, instead of 2-3. It does not update the new maximun value.

    thanks

    --tolga

     

  5. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 20 Mar 2009 Link to this post

    Here is more code...
    Try to follow my example. By default, the slider is set to 50 - 100. Now, enter 10 and 20 (anything where the new max value is less than than the previous min value) and hit "Update". You will notice it does not work.

    Regards
    --tolga koseoglu

    C#

     

    public Page()

     

    {

    InitializeComponent();

     

    this.Loaded += new RoutedEventHandler(Page_Loaded);

     

    }

     

    void Page_Loaded(object sender, RoutedEventArgs e)

     

    {

     

    this.btnUpdateSlider.Click += new RoutedEventHandler(btnUpdateSlider_Click);

     

     

    this.UpdateMySlider();

     

    }

     

    void btnUpdateSlider_Click(object sender, RoutedEventArgs e)

     

    {

     

    this.UpdateMySlider();

     

    }

     

    void UpdateMySlider()

     

    {

    dMinimum =

    Convert.ToDouble(this.txtMinimum.Text);

     

    dMaximum =

    Convert.ToDouble(this.txtMaximim.Text);

     

     

    this.myslider.TickFrequency = dMaximum;

     

     

    this.myslider.TickPlacement = Telerik.Windows.Controls.TickPlacement.TopLeft;

     

     

    this.myslider.Maximum = dMaximum;

     

     

    this.myslider.Minimum = dMinimum;

     

     

    this.myslider.SelectionEnd = dMaximum;

     

     

    this.myslider.SelectionStart = dMinimum;

     

     

    this.myslider.UpdateLayout();

     

    }

    xaml

     

    <

     

    UserControl x:Class="SilverlightTestoutStuff.Page"

     

     

     

     

     

     

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

     

     

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

     

     

    xmlns:telerikControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"

     

     

     

     

     

     

    Width="400" Height="300">

     

     

     

     

     

     

     

    <Grid x:Name="LayoutRoot" Background="White">

     

     

     

     

     

     

     

    <Grid.RowDefinitions>

     

     

     

     

     

     

     

    <RowDefinition

     

     

     

     

     

     

    Height="40"></RowDefinition>

     

     

     

     

     

     

     

    <RowDefinition

     

     

     

     

     

     

    Height="*"></RowDefinition>

     

     

     

     

     

     

     

    </Grid.RowDefinitions>

     

     

     

    <StackPanel Orientation="Horizontal">

     

     

     

     

     

     

     

    <Button

     

     

     

     

     

     

    x:Name="btnUpdateSlider"

     

     

     

     

     

     

    Content="Update"

     

     

     

     

     

     

    Width="60"

     

     

     

     

     

     

    HorizontalAlignment="Left"></Button>

     

     

     

     

     

     

     

    <TextBox

     

     

     

     

     

     

    x:Name="txtMinimum"

     

     

     

     

     

     

    Text="50"

     

     

    Width="30"

     

     

     

     

     

     

    Height="20"></TextBox>

     

     

     

     

     

     

     

    <TextBox

     

     

     

     

     

     

    x:Name="txtMaximim"

     

     

     

     

     

     

    Text="100"

     

     

     

     

     

     

    Width="30"

     

     

     

     

     

     

    Height="20"></TextBox>

     

     

     

     

     

     

     

    </StackPanel>

     

     

     

     

     

     

     

    <telerikControls:RadSlider

     

     

     

     

     

     

    Margin="15,10,15,10"

     

     

     

     

     

     

    VerticalAlignment="Center"

     

     

     

     

     

     

    Grid.Column="1"

     

     

     

     

     

     

    Grid.Row="1"

     

     

     

     

     

     

    IsSelectionRangeEnabled="True"

     

     

     

     

     

     

    HandlesVisibility="Visible"

     

     

     

     

     

     

    x:Name="myslider"

     

     

     

     

     

     

    Maximum="0">

     

     

     

     

     

     

     

    <telerikControls:RadSlider.TickTemplate>

     

     

     

     

     

     

     

    <DataTemplate>

     

     

     

     

     

     

     

    <Grid>

     

     

     

     

     

     

     

    <TextBlock

     

     

     

     

     

     

    Text="{Binding}"

     

     

     

     

     

     

    FontSize="10"

     

     

     

     

     

     

    Foreground="Black"

     

     

     

     

     

     

    FontFamily="Verdana"></TextBlock>

     

     

     

     

     

     

     

    </Grid>

     

     

     

     

     

     

     

    </DataTemplate>

     

     

     

     

     

     

     

    </telerikControls:RadSlider.TickTemplate>

     

     

     

     

     

     

     

    </telerikControls:RadSlider>

     

     

     

     

     

     

     

    </Grid>

     

    </

     

    UserControl>

     

     

     


     

  6. Bobi
    Admin
    Bobi avatar
    513 posts

    Posted 23 Mar 2009 Link to this post

    Hi Tolga,

    I reviewed you example and noticed that you set the Maximum before the Minimum value:

    void UpdateMySlider()
            {
                dMinimum = Convert.ToDouble(this.txtMinimum.Text);
                dMaximum = Convert.ToDouble(this.txtMaximim.Text);
                this.myslider.TickFrequency = dMaximum;
                this.myslider.TickPlacement = Telerik.Windows.Controls.TickPlacement.TopLeft;
              
      this.myslider.Maximum = dMaximum;
                this.myslider.Minimum = dMinimum;

                this.myslider.SelectionEnd = dMaximum;
                this.myslider.SelectionStart = dMinimum;
                this.myslider.UpdateLayout();
            }


    You have to set the minimum before the maximum and the example should work perfectly:

                this.myslider.Minimum = dMinimum;
                this.myslider.Maximum = dMaximum;


    You need to do so, because of a safeguard mechanism which is built into the control and prevents one from setting a Maximum value that is less than the Minimum and vice versa.

    I hope this answers your question.

    Regards,
    Boryana
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  7. joe castle
    joe castle avatar
    39 posts
    Member since:
    Jan 2005

    Posted 26 May 2009 Link to this post

    Hi,

    It seems that the UI is not updated when setting Minimum and Maximum to the same value from code. My slider's min/max value changes based on user input, and when setting first: min=1, max=10 works fine; later setting min=1, max=1 leads to no change on the slider, still showing max 10. So i guess the mentioned safeguard mechanism should handle min = max.

    Thanks,
    Joe
  8. Bobi
    Admin
    Bobi avatar
    513 posts

    Posted 28 May 2009 Link to this post

    Hi joe castle,

    Thank you for reporting this. We will see how we can improve this for the Q2 release.


    Best wishes,
    Boryana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. joe castle
    joe castle avatar
    39 posts
    Member since:
    Jan 2005

    Posted 05 Jan 2010 Link to this post

    Hi,

    As I can see, this problem is still there. Or is it fixed but I have to do some code changes?

    Thank you
  10. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 05 Jan 2010 Link to this post

    Hello Joe,

    I am not sure that I was able to reproduce the issue you describe. I have attached a sample project that allows you to set different values for min and max of RadSlider. Could you please take a look at the project and let me know if you are still able to reproduce the issue. I'd be glad to further assist you.

    Kind regards,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. joe castle
    joe castle avatar
    39 posts
    Member since:
    Jan 2005

    Posted 05 Jan 2010 Link to this post

    Hello Kiril,

    Thank you for the example, it works as expected here too. But I have a TickTemplate that I use and that in combination with TickPlacement="BottomRight" makes it not to update the UI correctly. If you replace the slider with this you will hopefully see the issue.

    <telerik:RadSlider x:Name="slider1" Width="276" Margin="0 10" IsSnapToTickEnabled="True" BorderThickness="10,0,0,0" TickPlacement="BottomRight"  > 
        <telerik:RadSlider.TickTemplate> 
            <DataTemplate> 
                <Grid> 
                    <TextBlock x:Name="tickBox" Text="{Binding}" FontSize="9" Foreground="Gray" ToolTipService.ToolTip="Jump to this page." Cursor="Hand" /> 
                </Grid> 
            </DataTemplate> 
        </telerik:RadSlider.TickTemplate> 
    </telerik:RadSlider> 


    Thanks
  12. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 05 Jan 2010 Link to this post

    Hi Joe,

    Thank you for clarifying. Indeed when Minimum equals Maximum the tick is not updated. We will do our best a fix is included in our next week's Service Pack release.

    All the best,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner