I have two styles set in my UserControl.Resources
<Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="white" /> </Style> <Style TargetType="{x:Type Label}"> <Setter Property="Foreground" Value="white" /> </Style>
So that in my DataTemplate
(and note that I chopped the rest off) I will have white text applied without having to change the properties on each and every Label
and TextBlock
element.
<DataTemplate x:Key="FileTransferItemTemplate">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="Transferring With: " />
<TextBlock Text="{Binding Path=OtherUserName, Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
What happens though(and this caused me a long nightmare where I thought I was databinding improperly because I couldn't see any changes), is when the data is bound the foreground color defaults to black. My databound text was black on a black background, and I didn't even realize for the longest time.
The only way I can override this is manually setting the Foreground="White"
on the TextBlock
. The Label
works fine for the color, because it's not databound.
Why is this happening, and how can I fix it?