问题
I Want To Change Color of ReadOnly Textbox
It is Possible To Change Default Color to white Color
<Style TargetType="TextBox">
<Setter Property="Background"
Value="White"/>
<Setter Property="Foreground"
Value="Black"/>
</Style>
and textbox as
<TextBox Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch" Height="18" Padding="0" IsReadOnly="True" Margin="3,0,3,0"/>
Thanks In Advance
回答1:
The problem is not that the Background Setter doesn't work, it is that the ReadOnly state for the TextBox has a gray overlay.
There are two options here:
- Edit the control template for the TextBox in Expression Blend, and get rid of the overlay.
- Set IsReadOnly to false and set IsHitTestVisible to false, this will prevent editting of the TextBox without changing its Visual State.
来源:https://stackoverflow.com/questions/14700272/how-to-change-background-colors-in-readonly-textbox-in-silverlight-5