Share via

Expander foreground property does not work while adding the header into the TextBlock in WPF

Hari Prasad M 1 Reputation point
2020-12-18T11:21:36.103+00:00

I am trying to use the textblock for the expander header property to visualize the text properly. But the foreground property doesnt update because trigger fails to update for the Is Pressed property while using the textblock. If I gave the header content directly it works perfectly fine. Here I am providing the comparison between the two codes.

Expander header with TextBlock:

<Expander Margin="5" x:Name="expander">
<Expander.Header>
<TextBlock
Margin="4"
FontSize="12"
FontWeight="Bold"
Text="WPF" />
</Expander.Header>
<TextBlock TextWrapping="Wrap" Margin="10">
Windows Presentation Foundation (WPF) is a UI framework that creates desktop client applications. The WPF development platform supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding, documents, and security. The framework is part of .NET, so if you have previously built applications with .NET using ASP.NET or Windows Forms, the programming experience should be familiar. WPF uses the Extensible Application Markup Language (XAML) to provide a declarative model for application programming.
</TextBlock>
</Expander>

Expander Header without TextBlock:

<Expander Margin="5" x:Name="expander" Header="WPF">
<TextBlock TextWrapping="Wrap" Margin="10">
Windows Presentation Foundation (WPF) is a UI framework that creates desktop client applications. The WPF development platform supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding, documents, and security. The framework is part of .NET, so if you have previously built applications with .NET using ASP.NET or Windows Forms, the programming experience should be familiar. WPF uses the Extensible Application Markup Language (XAML) to provide a declarative model for application programming.
</TextBlock>
</Expander>

So please provide me a solution for this issue.

Regards,

Hari Prasad

Developer technologies | Windows Presentation Foundation

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.