dotnet / dotnet/wpf

Calendar year view issue

Open
#8,273 2 comments 0 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

When a Calendar's DisplayMode is set to "Year" in XAML and a DataContext is set, the control will be very wide at runtime. If no DataContext is set either in the ancestors or in the control, it works fine. If DisplayMode = "Month" in XAML (or not set), then there is also no problem when switching to "Year" view.

![Wpf_Calendar_Issue](https://github.com/dotnet/wpf/assets/10571454/993edd17-0197-4aac-909e-1ed4f7e1c063)

### Reproduction Steps

**Wrong look:**
``
` `
` `
` `
``

**Wrong look:**
``
` `
` `
` `
``

**Right look:**
``
` `
` `
` `
``

### Expected behavior

Normal width as in Month view.

### Actual behavior

The all instances of CalendarItemStyle's "CalendarItem.DayTitleTemplateResourceKey" element (day titles) display data source string representation (ToString()), but not visible because the DataTrigger hides it (Visibility = Hidden). Set visible to display the text on the screen.

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

[WpfCalendarYearViewIssue.zip](https://github.com/dotnet/wpf/files/12826619/WpfCalendarYearViewIssue.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.