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

Styling RadComboBox

2 Answers 70 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ken Jones
Top achievements
Rank 1
Ken Jones asked on 20 Dec 2011, 05:28 PM
Hello,

This should be a fairly simple thing but I have searched the forums and others seem to be having similar issues and I havent been able to apply the solutions from any of the other posts.

I would like to apply a red border to the RadComboBox when a button is pressed, this is acheived simply for a standard silverlight ComboBox by the following:

App.xaml:
<Style TargetType="ComboBox" x:Key="RedBorderComboBox">
    <Setter Property="BorderBrush" Value="Red" />
    <Setter Property="BorderThickness" Value="1" />
</Style>

Page.xaml.cs:
Style redBorderStyleComboBox = Application.Current.Resources["RedBorderComboBox"] as Style;
 
var cb = control as ComboBox;
if (cb.SelectedValue == null)
{
    cb.Style = redBorderStyleComboBox;
}

Please can someone explain how to acheive this with a RadComboBox?

Thanks,
Ken

2 Answers, 1 is accepted

Sort by
0
Accepted
Dani
Telerik team
answered on 21 Dec 2011, 02:37 PM
Hello Ken,

If you apply a Style to RadComboBox dynamically, you will have to recreate the control so it can pick up the new style. Otherwise, your Style will not get applied.

Instead, you can simply try setting the BorderBrush property to Red:
if (this.cb.SelectedValue == null)
            {
                this.cb.BorderBrush = new SolidColorBrush(Colors.Red);
            }

But still, it depends when exactly you wish draw a red border around the control. If you are doing any kind of data validation, you can use the Validation visual states of RadComboBox for your customization. By default RadComboBox does include a ValidationToolTip, which you can see demonstrated in the Data Validation online example.

I hope this helps.

Regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Ken Jones
Top achievements
Rank 1
answered on 21 Dec 2011, 02:53 PM
Thanks for your feedback, I like the validation example but to remain consistent I will go with your other approach which works well.

Cheers,

Ken
Tags
ComboBox
Asked by
Ken Jones
Top achievements
Rank 1
Answers by
Dani
Telerik team
Ken Jones
Top achievements
Rank 1
Share this question
or