RS4 and lower: Cannot find a Resource with the Name/Key CalendarDatePickerTopHeaderMargin
See original GitHub issueOn RS4 and lower, this xaml will hit an error:
<CalendarDatePicker Header="MyHeader" />
Cannot find a Resource with the Name/Key CalendarDatePickerTopHeaderMargin
In my testing, I was not directly hitting an app crash due to this issue. The error gets swallowed along the way due to the fact that the header element is a defer load element in the tree. But it does result in a stowed exception and it causes the Header not to appear.
In some cases this may have knock on effect that cause a crash. Tipa in #2583 reported seeing a crash due to this error.
The issue is due to the fact that DefaultCalendarDatePicker in CalendarDatePicker_themeresources.xaml references the resource CalendarDatePickerTopHeaderMargin which was added to the OS in RS5.
The fix is to include the resource directly in WinUI so that it is not dependent on the resource being available in the OS.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top GitHub Comments
I am about to push a fix. 😃
@andrewleader This should be fixed in the newest WinUI 2.5 previews (200708003 and 200812001).
If you can’t use those preview versions, you also use the following workaround on 2.4 and below (from @kmahone):
Add the following XAML to your Application resource dictionary: