This is a migrated thread and some comments may be shown as answers.

Binding a color to the BorderBrush

1 Answer 550 Views
NumericBox for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 19 Jul 2014, 05:15 PM
I've seen the examples of creating a custom theme (using this Telerik link) for the NumericBox and I can successfully get that to work. However, I'd like to dynamically change the border brush for the TelerikNumericBoxBorderBrush. In other words, I'd like to do something like this:

<telerik:RadNumericBox BorderBrush={Binding ElementName=Qty, Path=Value, Converter={StaticResource ThresholdConverter}} />

Where the converter returns a SolidColorBrush of different colors depending on the value entered into the NumericBox. My converter works properly, but I haven't been able to figure out where to use it with the NumericBox, as the Telerik examples seem to assume that these colors will only be set once within a ResourceDictionary. I've also tried this, without success:

<telerik:RadNumericBox.Resources>
<Style TargetType="telerik:RadNumericBox">
       <Setter Property="InputScope" Value="Number"/>
       <Setter Property="MinWidth" Value="100"/>
       <Setter Property="Width" Value="120"/>
       <Setter Property="Maximum" Value="32676"/>
       <Setter Property="BorderBrush" Value="{Binding ElementName=Qty, Path=Value, Converter={StaticResource ThresholdConverter}}"/>
</Style>
</telerik:RadNumericBox.Resources>

How should I approach this? Thanks.

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 23 Jul 2014, 03:37 PM
Hi Tim,

The RadNumericBox component BorderBrush property is applied statically in its ControlTemplate and it cannot be dynamically changed through binding. This means that you would first have to edit its default ControlTemplate to TemplateBind the BorderBrush and BorderThickness properties accordingly.

Then you can go ahead and use a binding through a converter in the RadNumericBox definition. For your convenience I created a sample solution demonstrating this approach. Please have a look at it and let me know if it helps.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
NumericBox for XAML
Asked by
Tim
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or