question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RS4 and lower: Cannot find a Resource with the Name/Key CalendarDatePickerTopHeaderMargin

See original GitHub issue

On 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kmahonecommented, Jun 19, 2020

I am about to push a fix. 😃

0reactions
Felix-Devcommented, Aug 26, 2020

@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:

<Thickness x:Key="CalendarDatePickerTopHeaderMargin">0,0,0,4</Thickness>
Read more comments on GitHub >

github_iconTop Results From Across the Web

XamlParseException on RS4 & RS5 · Issue #2583
I've filed a separate issue for the 'CalendarDatePickerTopHeaderMargin' issue: #2719 RS4 and lower: Cannot find a Resource with the Name/Key ...
Read more >
Cannot find a Resource with the Name/Key
When I attempt to instantiate the UserControl, it's throwing an exception because in the XAML of the UserControl it's using a Style defined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found