Changing the Foreground colour of a contentpresenter in a listbox

有些话、适合烂在心里 提交于 2019-11-30 11:20:55
BrightShadow

There is also another way. You can add in your ContentPresenter this attribute

TextBlock.Foreground="YourColour"

In this case you can also use animations over that property.

It's all ok, I have managed to answer this question myself, I was trying to modify the foreground/fontweight of the contentpresenter which doesn't contain a definition for foreground/fontweight all i simply needed to do was this:

<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="White"/>

i.e. remove the:

TargetName="DisplayText"
Factor Mystic

Based on this related answer, I was able to solve a similar issue with the following:

<Setter TargetName="ctContentPresenter" Property="TextBlock.Foreground" Value="{StaticResource StyleForeColorBrush}" />
  <Storyboard x:Key="Storyboard1">  
       <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="myContentPresenter">
        <EasingColorKeyFrame KeyTime="0" Value="Black"/>
        <EasingColorKeyFrame KeyTime="0:0:0.2" Value="White"/>
       </ColorAnimationUsingKeyFrames>        
  </Storyboard>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!