locked
Bug binding to Slider.Maximum

    Question

  • If you look at this: http://mister-j.dyndns.org/peterj/pete/SilverlightApplication1TestPage.html

    It binds the values 3 and 5 to the Minimum and Maximum values of the slider. However, the Maximum binding isn't picked up.

     

    The source is this:

    XAML:

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <TextBlock Grid.Column="0" Text="{Binding MinValue}" VerticalAlignment="Center"/>
        <Slider Name="slider" Grid.Column="1" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" />
        <TextBlock Grid.Column="2" Text="{Binding MaxValue}" VerticalAlignment="Center"/>
        <TextBlock Grid.Row="1" Grid.ColumnSpan="3" Text="{Binding Info}" />
      </Grid>
    

    and the code is this:

    public partial class MainPage: UserControl
      {
        public double MinValue { get; set; }
        public double MaxValue { get; set; }
    
        public string Info
        {
          get
          {
            return "Slider Minimum = " + slider.Minimum + ", Maximum = " + slider.Maximum;
          }
        }
    
        public MainPage()
        {
          MinValue = 3.0;
          MaxValue = 5.0;
    
          DataContext = this;
    
          InitializeComponent();
        }
      }
    

    Friday, August 5, 2011 11:38 AM

Answers

All replies

  • BTW I am using the Silverlight 5 beta runtime
    Friday, August 5, 2011 11:40 AM
  • Hi, this is a known (annoying) problem.

    Read this blog post: http://dotnetbyexample.blogspot.com/2009/08/bind-silverlight-3-slider-value-minimum.html

    Also Silverligth 4 is affected by this problem, while WPF4 isn't.

    In a nutshell, try change

    <Slider Name="slider" Grid.Column="1" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}" />
    

    into

    <Slider Name="slider" Grid.Column="1" Maximum="{Binding MaxValue}" Minimum="{Binding MinValue}" />
    

    • Marked as answer by Mr J5 Monday, August 15, 2011 2:06 PM
    Monday, August 8, 2011 11:03 PM
  • Still applies to Silverlight 5 as well.
    Tuesday, January 10, 2012 5:59 PM
  • Still applies to Silverlight 5 as well.

    The bug remains unfixed as of May 2013 and impacts Surface Store apps, in addition see this other bug too.

    I'm trying to do pretty basic stuff on a Surface and so far have found two bugs in Slider, this latest one being quite serious with no apparent workaround.

    Cap'n

    Wednesday, May 8, 2013 6:19 PM