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
85
XamNumericEditor cannot bind decimal value to ValueConstraint
posted

I'm trying to bind a decimal value (SalePrice) from my database to the MaxInclusive property of a ValueConstraint like this:

<Label Margin="0,0,4,0" Content="{Binding Path=SalePrice}"/>
<igEditors:XamNumericEditor x:Name="xnumAmountSaleRefunded">
   <igEditors:XamNumericEditor.ValueConstraint>
       <igEditors:ValueConstraint ValidateAsType="Decimal" MinInclusive="0" MaxInclusive="{Binding Path=SalePrice, Mode=OneWay}"  />
   </igEditors:XamNumericEditor.ValueConstraint>
</igEditors:XamNumericEditor>

I added a lable just above the XamNumericEditor just to verify that the binding to SalePrice works, and it does.  It shows a value of 24.95 when run.

The SalePrice field in the SQL database is defined as Decimal(10,2).

The problem is that the constraint just doesn't seem to do anything.  I can enter any max value and it doesn't catch it.

If I change it to say MaxInclusive="24.95", of course it works.  I've tried it with and without the Mode=OneWay, and  I've also tried changing the ValidateAsType to Float, Double, Unknown, even Integer64 and a few others and nothing seems to work.

What am I doing wrong?

Parents
  • 75
    posted

    Hi, I am evaluating the Infragistics WPF controls, I seem to have the same problem:

    <igEditors:XamNumericEditor

    Value=

    "{Binding Path=ValueMine, diag:PresentationTraceSources.TraceLevel=High, ElementName=MyNumEdit, Mode=TwoWay}" 

                                        x:Name="MySpinner" 

                                        HorizontalAlignment="Left"

                                        Margin="10,42,0,0" 

                                        Mask="{}{double:6.2}" 

                                        PromptChar=" " 

                                        SpinButtonDisplayMode="Always" 

                                        SpinIncrement="0.5"  

                                        ValueType="{x:Type my:Double}" 

                                        VerticalAlignment="Top" Width="138">

                <igEditors:XamNumericEditor.ValueConstraint>

                    <igEditors:ValueConstraint 

                        MaxInclusive=

    "{Binding Path=ValueMaxMine, diag:PresentationTraceSources.TraceLevel=High, ElementName=MyNumEdit, Mode=TwoWay }" 

                        MinInclusive=

    "{Binding Path=ValueMinMine, diag:PresentationTraceSources.TraceLevel=High, ElementName=MyNumEdit, Mode=TwoWay}"

                        />

                </igEditors:XamNumericEditor.ValueConstraint>

            </igEditors:XamNumericEditor>

     

    Looking at the output window :

    ...

    System.Windows.Data Warning: 65 : BindingExpression (hash=50340407): Resolving source  (last chance)

    System.Windows.Data Warning: 67 : BindingExpression (hash=50340407): Framework mentor not found

    System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=ValueMaxMine; DataItem=null; target element is 'ValueConstraint' (HashCode=50690790); target property is 'MaxInclusive' (type 'Object')

    System.Windows.Data Warning: 65 : BindingExpression (hash=50070782): Resolving source  (last chance)

    System.Windows.Data Warning: 67 : BindingExpression (hash=50070782): Framework mentor not found

    System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=ValueMinMine; DataItem=null; target element is 'ValueConstraint' (HashCode=50690790); target property is 'MinInclusive' (type 'Object')


    The binding for the 'Value' works just fine. This is regardless of being in a user control or not.
    Hans

Reply Children