I'm still learning Blend, so please bear with me. I have a toggle button in a WPF project and I need to change the text color for different states such as mouseover and checked. However, when I'm editing the template and I select the contentPresenter, the only brush is OpacityMask and it is not affected by any brush color changes.
I can of course change the text color by editing the style, but this is not useful as it is within the states I'm interesting in editing.
Basically, I simply want the text of the button to change on mouseover, hover, etc, this seems a reasonable thing to do, but the OpacityMask Brush of the ContentPresenter cannot be edited.
Someone mentioned to change the ContentPresenter into a ContentControl. This does work, but I now cannot edit the text for an instance of the button. Do I have to link the ContentControl to something?
Many thanks for any help. I'm stuck right here for a few hours and I've been searching everywhere for the answer, to no avail
Foreground property is present in Style. So you can edit Style and there you can set Foreground
. It could be something like this
<Style.Triggers>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Foreground" Value="Blue"/>
</Trigger>
</Style.Triggers>
Or if you want to change it in ControlTemplate
then you can do it like this.
<Trigger Property="IsChecked" Value="True">
<Setter Property="TextBlock.Foreground" TargetName="contentPresenterName" Value="White"/>
</Trigger>
So in expression blend you do it like this