Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2815
using ValueConstraint with binding
posted

I have this XAML:

<igEditors:XamNumericEditor Grid.Column="6" Margin="6,1,0,1" Grid.Row="1" Style="{StaticResource XamLongEditor}" Value="{Binding LogIdEnd, Mode=TwoWay}" Grid.ColumnSpan="1" IsEnabled="{Binding ElementName=UseLogIdEnd, Path=IsChecked, Mode=OneWay}" >

 

 

 

 

 

<igEditors:XamMaskedEditor.ValueConstraint><igEditors:ValueConstraint MinInclusive="{Binding LogIdStart, Mode=OneWay}"/></igEditors:XamMaskedEditor.ValueConstraint></igEditors:XamNumericEditor>

where LogIdStart is the value I want to be used as minimum.  When I change LogIdStart, MinInclusive constraint is not enforced based on LogIdStart.

What am I missing?

Parents
No Data
Reply
  • 2815
    posted

    This seems to be a common request so why don't you just add Min and Max dependency properties like so?

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    public class XamNumberEditor :

    XamNumericEditor

    {

     

     

    public object

    MinValue

    {

     

     

    get { return

    GetValue(MinValueProperty); }

     

     

    set { SetValue(MinValueProperty, value

    ); }

    }

     

     

    public static readonly DependencyProperty

    MinValueProperty =

     

     

    DependencyProperty

    .Register(

     

     

    "MinValue"

    ,

     

     

    typeof(object

    ),

     

     

    typeof(XamNumberEditor

    ),

     

     

    new UIPropertyMetadata(null

    , MinValueChangedCallback));

     

     

     

    static void MinValueChangedCallback(DependencyObject depObj, DependencyPropertyChangedEventArgs

    e)

    {

    (depObj

     

    as XamNumberEditor

    ).OnMinValueChanged();

    }

     

     

    protected void

    OnMinValueChanged()

    {

     

     

    if (ValueConstraint == null

    )

    ValueConstraint =

     

    new ValueConstraint

    ();

    ValueConstraint.MinInclusive = MinValue;

    }

     

     

    public object

    MaxValue

    {

     

     

    get { return

    GetValue(MaxValueProperty); }

     

     

    set { SetValue(MaxValueProperty, value

    ); }

    }

     

     

    public static readonly DependencyProperty

    MaxValueProperty =

     

     

    DependencyProperty

    .Register(

     

     

    "MaxValue"

    ,

     

     

    typeof(object

    ),

     

     

    typeof(XamNumberEditor

    ),

     

     

    new UIPropertyMetadata(null

    , MaxValueChangedCallback));

     

     

     

    static void MaxValueChangedCallback(DependencyObject depObj, DependencyPropertyChangedEventArgs

    e)

    {

    (depObj

     

    as XamNumberEditor

    ).OnMaxValueChanged();

    }

     

     

    protected void

    OnMaxValueChanged()

    {

     

     

    if (ValueConstraint == null

    )

    ValueConstraint =

     

    new ValueConstraint

    ();

Children
No Data