3
votes

In Windows Phone 7, a textbox with IsReadOnly property is set to true, when it runs (at least in the Beta emulator), even with Background color set to Black and Foreground color set to White, the background remains gray with the foreground chars a lighter gray. I need to change this so it is readable!

So is there a way to override this?

I've tried setting it to something else in the textbox load event, but it hasn't worked. Apparently setting ReadOnly to true sets the fore/background colors in stone.

Here would be some code to change the colors, if they could be changed:

SolidColorBrush ForeBrush = new SolidColorBrush();
SolidColorBrush BackBrush = new SolidColorBrush();
ForeBrush.Color = Colors.White;
BackBrush.Color = Colors.Black;
txtFrom.Foreground = ForeBrush;
txtFrom.Background = BackBrush;
2

2 Answers

3
votes

I think that template of textbox contains visual style for read-only textbox. Therefore you can't set other style. But you can try to change template for textbox also as any other silverlight control:

<TextBox ..>
  <TextBox.Template>
    ...
  </TextBox.Template>
</TextBox>
0
votes

You can attach a blank ManipulationStarted event to the text box , then you do not have to set isreadonly true. it is a hack but will serve the purpose.