Unable to set forecolor for RadTextBox

5 posts, 0 answers
  1. Terry
    Terry avatar
    4 posts
    Member since:
    Nov 2013

    Posted 11 Nov 2013 Link to this post


    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

  2. Terry
    Terry avatar
    4 posts
    Member since:
    Nov 2013

    Posted 12 Nov 2013 Link to this post

    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 ? 
  3. DevCraft banner
  4. Todor
    Admin
    Todor avatar
    778 posts

    Posted 12 Nov 2013 Link to this post

    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.
  5. Terry
    Terry avatar
    4 posts
    Member since:
    Nov 2013

    Posted 12 Nov 2013 Link to this post


    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
  6. Todor
    Admin
    Todor avatar
    778 posts

    Posted 15 Nov 2013 Link to this post

    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.
Back to Top
DevCraft banner