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
2387
data binding to ValueConstraint
posted

The ValueConstraint.MaxLength needs to be data bound.  I have tried using DataBinding and it is not working, though I can use the exact same Binding statement at the same level and get the correct value.

I posted a question in the MSDN forum and they did not see anything wrong with the code, they did state that the MaxLength needs to be a dependency property of a Framework element...

 Here is the code:

<igEditors:XamTextEditor 

    Margin="8,1"

Text="{Binding Answer, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"                         

Visibility="{Binding ResponseParam, Converter={StaticResource EditorVisibilityConverter}, Mode=OneWay}"

>

 

 

<!-- This does NOT work -->

    <igEditors:XamTextEditor.ValueConstraint>

<igEditors:ValueConstraint MaxLength="{Binding ResponseParam.MaxLength, Mode=OneWay}" />

    </igEditors:XamTextEditor.ValueConstraint>

 

 

    <igEditors:XamTextEditor.ToolTip>

<WrapPanel>

<StackPanel Orientation="Horizontal">

<TextBlock Text="Maximum Length: " FontWeight="Bold"/>

<!-- This works JUST fine -->

<TextBlock Text="{Binding ResponseParam.MaxLength, Mode=OneWay}"/>

</StackPanel>

</WrapPanel>

    </igEditors:XamTextEditor.ToolTip>     

 

</igEditors:XamTextEditor>

  • 69686
    posted

    Hello,

    That is correct, the ValueConstraint is not an element in the visual tree of the application and cannot be data bound. What you can do, is create a converter (IValueConverter) that will return a ValueConstraint object. Then you can apply the binding at the ValueConstraint property with the converter.

    Hope this helps.