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

How to change the Background color of a RadControl in runtime?

2 Answers 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Di
Top achievements
Rank 1
Di asked on 05 Jul 2013, 06:42 PM
I have two radcontrols:
<telerik:RadMaskedNumericInput Name="txtC" Value="{x:Null}" IsClearButtonVisible="False" Height="30" Width="50" Mask="###" Placeholder=" " HorizontalContentAlignment="Right" HorizontalAlignment="Left" VerticalContentAlignment="Center" ValueChanged="txtC_ValueChanged" />

and I need to know how to change the background color according to the numbers the user is going to type.
eg: 
if (!string.IsNullOrWhiteSpace(txtAltura.Text))
{
   txtC.Background = "Green";
   // or
   txtC.Background = ColorNames.Green;
}

I already checked other solutions with System.Windows.Media.BrushConverter, but it doesn't appear in my codebehind, even using the namespace. I am using VS 2010.

Di.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 08 Jul 2013, 01:27 PM
Hi Di,

Please have a look at the sample C# code I tried to set the background of RadRichTextBox.

C#:
radRichTextBox.Background = new SolidColorBrush(Colors.Green);

Also you can directly modify the background color of the active presenter like this:

C#:
((Control)radRichTextBox.ActiveEditorPresenter).Background = new SolidColorBrush(Colors.Yellow);

Thanks,
Shinu.
0
Di
Top achievements
Rank 1
answered on 08 Jul 2013, 02:25 PM
Thanks Shinu.
Tags
General Discussions
Asked by
Di
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Di
Top achievements
Rank 1
Share this question
or