Question

So my issue is this, I have in WPF a button with a ContentPresenter that has a resource of a textblock:

<ContentPresenter Name="contentHolder" Width="55.77" Height="10.979" RenderTransformOrigin="0.5,0.5" Canvas.Left="3.646" Canvas.Top="9.608" 
                          Margin="2"                              
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"                              
                          RecognizesAccessKey="True">
   <ContentPresenter.Resources>
      <Style TargetType="{x:Type TextBlock}">
         <Setter Property="HorizontalAlignment" Value="Center"/>
         <Setter Property="VerticalAlignment" Value="Center"/>
         <Setter Property="FontFamily" Value="Arial"/>
         <Setter Property="FontSize" Value="10.667"/>
         <Setter Property="Foreground" Value="#FF141006"/>
         <Setter Property="TextAlignment" Value="Center"/>
         <Setter Property="TextWrapping" Value="Wrap"/>
      </Style>
   </ContentPresenter.Resources>
</ContentPresenter> 

and I have a storyboard that is changing the background colors of the button and it's content when (Normal/MousedOver/Pressed/and Disabled). Everything is working great....EXPECT the content of the button will not change text color when pressed. My ColorAnimationUsingKeyFrames looks like this:

<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentHolder" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
   <SplineColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>

As is said earlier all of my triggers and what not are working correctly, the only issue is that the text of the textBlock in the content presenter is not changing... does anyone have any insight on this matter?

Was it helpful?

Solution

Converting my comment to an answer.

does it work if you remove setting Foreground in the Style Setter of the ContentPresenter's Resources for TextBlock? If so could be a case of precedence ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top