Skip to content

Calendar year view issue #8273

@akikari

Description

@akikari

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

Reproduction Steps

Wrong look:
<Window x:Class="WpfCalendarYearViewIssue.MainWindow"
...
DataContext="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}">
<Grid>
<Calendar DisplayMode="Year"/>
</Grid>
</Window>

Wrong look:
<Window x:Class="WpfCalendarYearViewIssue.MainWindow"
...>
<Grid>
<Calendar DisplayMode="Year" DataContext="{Binding Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" DisplayDate="{Binding DateTimeValue}"/>
</Grid>
</Window>

Right look:
<Window x:Class="WpfCalendarYearViewIssue.MainWindow"
...>
<Grid>
<Calendar DisplayMode="Year"/>
</Grid>
</Window>

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateRequires further investigation by the WPF team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions