سؤال

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

هل كانت مفيدة؟

المحلول

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:

  1. Edit the control template for the TextBox in Expression Blend, and get rid of the overlay.
  2. Set IsReadOnly to false and set IsHitTestVisible to false, this will prevent editting of the TextBox without changing its Visual State.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top