MonthCalendar-DayOfWeekItem style edit not displaying

Editors for WPF Forum

Posted 9 years ago by Ivan
Version: 9.2.0515
Avatar
In the MonthCalendar control, I'm trying to change the DayOfWeekItem color to red without any luck. Any idea why it's not showing in red color?

<Style x:Key="MonthCalendarWeekItemStyle" TargetType="{x:Type editors:DayOfWeekItem}">
<Setter Property="Foreground" Value="Red" />
</Style>

Thanks,

Ivan

Comments (3)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ivan,

There are actually several brushes that come into play with MonthCalendar items. You are setting the "normal" brush, but not the "disabled", "hover", or "pressed" brushes. Since you are setting the Foreground with a Style, it has the same priority as the default/implicit Style. The default/implicit Style (which provides the themes) will change the Foreground based on the current state.

I'm assuming you currently have SelectionMode set to Single, in which case the day-of-week items are actually disabled. When you set SelectionMode to Extended and set IsDayOfWeekSelectionEnabled to true, then you would see the red foreground.

What you can do instead is change the brush resources used by the default/implicit Style. Something like this:
<Style x:Key="MonthCalendarWeekItemStyle" TargetType="{x:Type editors:DayOfWeekItem}"
        BasedOn="{StaticResource {x:Type editors:DayOfWeekItem}}">
    <Style.Resources>
        <SolidColorBrush x:Key="{x:Static themes:EditorsCommonDictionary.CalendarForegroundNormalBrushKey}" Color="Red" />
        <SolidColorBrush x:Key="{x:Static themes:EditorsCommonDictionary.CalendarForegroundDisabledBrushKey}" Color="Red" />
    </Style.Resources>
</Style>
This creates a Style that is based on the default/implicit Style, but alters the normal and disabled brushes. You could also change the hover and pressed brushes. Finally, I'm assuming you've hooked up the Style to the MonthCalendar like so:
<editors:MonthCalendar DayOfWeekItemStyle="{StaticResource MonthCalendarWeekItemStyle}" ... />


Actipro Software Support

Posted 9 years ago by Ivan
Avatar
Thanks so much for your reply!

Still have one problem, setting IsDayOfWeekSelectionEnabled to True, selects all days of the week. The selection mode should be single in our case.

Also, setting CalendarForegroundNormalBrushKey worked, the problem is the overlay that gives a disable look "gray out effect."

Any idea on how to approach this?

Ivan
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ivan,

Sorry, I just suggested changing the SelectionMode/IsDayOfWeekSelectionEnabled properties so you could see the various states and that the Red was being picked up.

The code I provided above should work as-is when SelectionMode is set to Single, as it sets the "disabled" look. Are you not seeing red text when you use the Style provided above?


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.