Feat: Add weeknumbers to Calendar#21311
Conversation
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
| <StaticResource x:Key="CalendarViewWeekNumberSeparatorForeground" | ||
| ResourceKey="SystemControlDisabledBaseMediumLowBrush" /> |
There was a problem hiding this comment.
As mentioned above, if the CalendarWeekNumberLabel goes away it would be needed to add CalendarViewWeekNumberForeground and related resources here.
| /// the appearance — for example <c>FontWeight="Bold"</c>. | ||
| /// Use the <c>:header</c> pseudo-class to target the column header cell (row 0). | ||
| /// </summary> | ||
| public sealed class CalendarWeekNumberLabel : ContentControl |
There was a problem hiding this comment.
IMO an entire new primitive probably isn't needed for this concept. It can be done with text and light-weight styling resources alone.
That in turn allows room for future expansion in this area. For example -- we might want to make it interactive as a button in some way, the calendar might get a week ONLY view, etc.
I'm also not a fan of the legacy term "Label" being used for new controls. That just isn't done in modern XAML.
0e2f4d5 to
49d4f91
Compare
…eat/CalendarWeekNumbers
naming can be hard. i am not sure about both naming ideas. We will see what team things
|
You can test this PR using the following package version. |
What does the pull request do?
Adds week number display to both
CalendarandCalendarDatePickerin month view (Fluent and Simple themes).What is the current behavior?
Calendar and CalendarDatePicker only show day-of-week headers and date cells in month view. There is no way to display week numbers alongside the calendar grid.
What is the updated/expected behavior with this PR?
IsWeekNumberVisible="True".WeekNumberHeader(e.g."#","CW","KW","Wk"— defaults to"#").WeekNumberRuleusing the newCalendarWeekNumberRuleenum. UseWeekNumberRule="Iso"for ISO 8601 week numbering; other values (FirstDay,FirstFullWeek,FirstFourDayWeek) map to the BCL equivalents. Defaults to the current culture's rule.CalendarDatePicker, where they propagate to the inner popup calendar.:hasweeknumberspseudo-class onCalendarItemis used in the Fluent theme to hold the minimum width stable.How was the solution implemented?
New type —
CalendarWeekNumberLabel(Avalonia.Controls.Primitives)A
ContentControlsubclass placed in column 0 ofPART_MonthView. Exposes a:headerpseudo-class for the top cell (row 0) so themes can style it differently from the data cells (rows 1–6).New enum —
CalendarWeekNumberRule(Avalonia.Controls)Avalonia-specific enum replacing the BCL
CalendarWeekRuleon theWeekNumberRuleproperty, with an additionalIsovalue:API diff
ISO 8601 week number fix —
DateTimeHelper.GetWeekOfYear.NET's
Calendar.GetWeekOfYearwithFirstFourDayWeek+Mondayincorrectly returns week 53 for late-December dates that ISO 8601 assigns to week 1 of the next year (e.g. 2018-12-31 → ISO week 1 of 2019). Both theIsoshorthand and the explicitFirstFourDayWeek+Mondaycombination delegate toISOWeek.GetWeekOfYearto avoid this bug:Checklist
Breaking changes
None.
Obsoletions / Deprecations
None.
Fixed issues
Fixes #7976