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

Unable to set forecolor for RadTextBox

4 Answers 95 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Terry
Top achievements
Rank 1
Terry asked on 11 Nov 2013, 02:36 PM

Hi,

     I am a newbie for Telerik components and am developing a Win Phone 8 app using it. I need to manage my foreground color for dark/light themes', how should it be managed ?
I am  somewhat new for WinPh8 also. I tried the following, but no success :

In

<phone:

PhoneApplicationPage have added

Foreground="{StaticResource PhoneForegroundBrush}"

 

<Controls:RadTextBox Grid.Row="0" HorizontalAlignment="Stretch" Text="{Binding FirstName, Mode=TwoWay}"

 ClearButtonVisibility="Visible" Watermark="First Name" />

In xml.cs constructor :

 

//PhoneForegroundBrush

Resources.Remove("PhoneForegroundBrush");

Resources.Add("PhoneForegroundBrush", System.Windows.Media.Colors.Red);

//((System.Windows.Media.SolidColorBrush)Resources["PhoneForegroundBrush"]).Color = System.Windows.Media.Colors.Magenta;   // THIS LINE GIVES ERROR

InitializeComponent();

Resources.Remove("PhoneForegroundBrush");

Resources.Add("PhoneForegroundBrush", System.Windows.Media.Colors.Red);

 

Still my fore color of textboxes is default only. When I change the theme from dark to light, I can't see anything that I enter in the textboxes.
I have several files & several textboxes used in my app, how do I sort out this problem.

Kindly help me solve the problem.

Thanks

4 Answers, 1 is accepted

Sort by
0
Terry
Top achievements
Rank 1
answered on 12 Nov 2013, 08:50 AM
I don't see my question that difficult that no help is available !!!!
Is it really that difficult Q, then how windows phone developers would be managing it ? 
0
Todor
Telerik team
answered on 12 Nov 2013, 09:38 AM
Hi Terry,

Here's how you can change the default resources, which are related to RadTextBox:

SolidColorBrush textBoxForegroundBrush = Application.Current.Resources["PhoneTextBoxForegroundBrush"] as SolidColorBrush;
textBoxForegroundBrush.Color = Colors.Green;
 
SolidColorBrush textBoxBrush = Application.Current.Resources["PhoneTextBoxBrush"] as SolidColorBrush;
textBoxBrush.Color = Colors.Blue;
 
SolidColorBrush editBackgroundBrush = Application.Current.Resources["PhoneTextBoxEditBackgroundBrush"] as SolidColorBrush;
editBackgroundBrush.Color = Colors.Purple;
 
SolidColorBrush borderBrush = Application.Current.Resources["PhoneTextBoxEditBorderBrush"] as SolidColorBrush;
borderBrush.Color = Colors.Orange;

I hope this information helps.
 
Regards,
Todor
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Terry
Top achievements
Rank 1
answered on 12 Nov 2013, 10:11 AM

Thanks Todor,

I got my solution from here

From your code, I tried with PhoneTextBoxForegroundBrush, but that also doesn't work on light theme (written text is not visible) . PhoneAccentBrush worked in all cases and themes.


Thanks
0
Todor
Telerik team
answered on 15 Nov 2013, 09:33 AM
Hello Terry,

Since you have found a solution, we will consider this thread closed.
 
Regards,
Todor
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
TextBox
Asked by
Terry
Top achievements
Rank 1
Answers by
Terry
Top achievements
Rank 1
Todor
Telerik team
Share this question
or