繰り返しますが、テキストボックスの背景色を変更することに固執していますが、奇妙な部分はフォアグラウンドであり、背景ではなく正常に機能します。
ここに私のxamlがあります
<TextBox
Name="tbHeadline"
Text="{Binding SelectedStory.Headline, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"
Grid.Column="1"
Grid.Row="6"
TextWrapping="NoWrap"
d:LayoutOverrides="Height"
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
LostFocus="tbHeadline_LostFocus"
/>
私のXaml.csで
次のコードがあります
tbHeadline.Background = Brushes.Gray; //this not working
tbHeadline.Foreground = Brushes.Gray; //this is working
ここにサンプル出力があります
ご協力いただきありがとうございます。
専門家のコメントからの更新
Okie、グリッドにテキストボックスを追加すると、これがどのように見えるか
<TextBox Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="10" Grid.RowSpan="2" Height="23" HorizontalAlignment="Left" Margin="50,14,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" Background="#E6000000" />
背景色を黒に設定しても、アプリケーションを実行すると表示されません。