Broken binding to 'Maximum' property

4 posts, 0 answers
  1. William
    William avatar
    15 posts
    Member since:
    Jun 2010

    Posted 03 Jul 2010 Link to this post

    Summary: Setting the 'Maximum' property to a value less than the 'Minimum' property causes any binding on the

    'Maximum' property to break.

    I have a control that has the following bindings:

    <telerik:RadNumericUpDown

    Minimum="0"

    Maximum="{Binding Path=SnapshotCount, ElementName=GameDisplay, Mode=OneWay, Converter={StaticResource

    SnapshotCountToMaxIndexConverter}}"

    Value="{Binding Path=SnapshotIndex, ElementName=GameDisplay, Mode=TwoWay}"

    />

    The problem is that when the SnapshotCountToMaxIndexConverter converter returns a value less than the minimum (in my particular case it was returning -1) then the following code is triggered to execute in RadRangeBase.cs:

     

    private void CoerceMaximum()

    {

    if (this.Maximum < this.Minimum)

    {

    this.SetValue(MaximumProperty, this.Minimum);

    }

     

    This appears to break the binding because afterwardsI can see via breakpoints that the

    OnMaximumPropertyChanged() method is no longer called.

    The net effect of this is that the control becomes unusable because the only value that can then be entered into the field is the minimum value since the minimum and the maximum values are the same and the binding doesn't update what the maximum should be.

     

    Interestly, I also have the exact same binding on a RadSlider() and the binding does not appear to break for that control.

    NOTE: This problem is easy to avoid by ensuring that you never specify a maximum value that is less than the minimum.

    PS: I love the controls by the way.

  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 08 Jul 2010 Link to this post

    Hello William,

    Thank you for contacting us.

    To make it work you will have to set the Binding Mode of the Maximum property to TwoWay. In that way the binding won't break when the maximum value is less than the minimum.

    If you have further questions please let us know.

    Kind regards,
    Konstantina
    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. UI for WPF is Visual Studio 2017 Ready
  4. William
    William avatar
    15 posts
    Member since:
    Jun 2010

    Posted 14 Jul 2010 Link to this post

    Hi Konstantina,
    Thank you for the reply but the solution you suggest won't work for me.

    1. The business logic is such that the maximum value is defined by the object being bound to and it would be undesirable for the control to be able to change its value. Thus a two way binding is undesirable.
    2. Even if this was something that was desirable to do, it is not possible since the bound property does not have a setter.

    Also, I'd like to point out that this does not explain why the binding works for the RadSlider control when the bindings are identical to the ones used by the RadNumericUpDown control.

    Enclosed for reference are the xaml declarations for both:

     

     

    <telerik:RadSlider

     

     

     

    Grid.Row="0"

     

     

     

    Grid.ColumnSpan="2"

     

     

     

    HorizontalAlignment="Stretch"

     

     

     

    Minimum="0"

     

     

     

    Maximum="{Binding Path=SnapshotCount, ElementName=GameDisplay, Mode=OneWay, Converter={StaticResource SnapshotCountToMaxIndexConverter}}"

     

     

     

    Value="{Binding Path=SnapshotIndex, ElementName=GameDisplay, Mode=TwoWay}"

     

     

     

    VerticalAlignment="Center"

     

     

     

    />

     

     


     

     

    <telerik:RadNumericUpDown

     

     

     

    Grid.Row="1"

     

     

     

    Grid.Column="1"

     

     

     

    IsInteger="True"

     

     

     

    Minimum="0"

     

     

     

    Maximum="{Binding Path=SnapshotCount, ElementName=GameDisplay, Mode=OneWay, Converter={StaticResource SnapshotCountToMaxIndexConverter}}"

     

     

     

    Value="{Binding Path=SnapshotIndex, ElementName=GameDisplay, Mode=TwoWay}"

     

     

     

    VerticalAlignment="Center"

     

     

     

    />

     

     


    Best regards,
    Pete
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 14 Jul 2010 Link to this post

    Hi William,

    Thank you for your reply.

    When the Mode is set to OneWay the binding is lost. For now in your case you have 2 options:
    1) To set the binding to TwoWay.
    2) To make sure that the Maximum is never less than the Minimum.
    We will research further the issue and provide a fix for it in one of our future releases. You can track this status in our Public Issue Tracking System with ID=2668. You can vote for it and see when it is going to be fixed.

    If you have further questions please feel free to contact us again.

    Sincerely yours,
    Konstantina
    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
Back to Top