TTGroup
TTGroup

Reputation: 3703

Change the text color on WPF Calendar?

I want to change the text color for special days on WPF Calendar.

I have researched the topic http://msdn.microsoft.com/en-us/magazine/dd882520.aspx, at the item "The RedLetterDays Display", it showed how to highlight the special days, but I want to change the color of special days only.

I read the code in XAML file, and I saw the important line

 <Rectangle x:Name="RedLetterDayBackground" IsHitTestVisible="False" Fill="#80FF0000" />\

The author use the rectangle to highlight special days.

Someone can show me how to edit this XAML code to solve my requirement, or if you have a other way to do it?

Many thanks,

T&

Upvotes: 1

Views: 3537

Answers (1)

Matt Ringer
Matt Ringer

Reputation: 1376

Changing your DataTrigger's target to the TextElement in CalendarDayButton instead of RedLetterDayBackground, will achieve the change you want.

<DataTrigger Binding="{Binding Converter={StaticResource conv}}" Value="{x:Null}">
   <Setter TargetName="CalendarDayButton" Property="TextElement.Foreground" Value="Red" />  
</DataTrigger>

Upvotes: 1

Related Questions