microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.35k stars 677 forks source link

Cannot find a Resource with the Name/Key TabViewItemHeaderBackground #1295

Closed icarlthiscode closed 5 years ago

icarlthiscode commented 5 years ago

After recent updates, UWP Unit Test App fails at InitializeComponent() within page using Microsoft.UI.Xaml.Controls.NavigationView.

Steps to reproduce the behavior:

  1. Create new Unit Test App (Universal Windows)
  2. Add Microsoft.UI.Xaml NuGet package
  3. Add MUXC to application resource
  4. Have UITestMethod navigate to page containing a MUXC NavigationView control

Expected behavior Test will not throw:

Windows.UI.Xaml.Markup.XamlParseException:..

Cannot find a Resource with the Name/Key TabViewItemHeaderBackground [Line: 18 Position: 69]'

Version Info Project Target Version: Win 10.0 18362 OS: Win 10.0 18362.329

NuGet package version: Microsoft.UI.Xaml 2.2.190830001

Windows 10 version Saw the problem?
May 2019 Update (18362) Yes
October 2018 Update (17763) No
Device form factor Saw the problem?
Desktop Yes
Mobile
Xbox
Surface Hub
IoT

Additional context

jevansaks commented 5 years ago

Dupe of #230 which has workaround instructions. It's an issue with the unit test project.

FrancoisM commented 5 years ago

I have the same error in a regular project (not unit test). I used that project to repro a bug which was supposed to be solved with WinUI2.2. But after upgrading from 2.1 I had the issue explained above.

crutkas commented 4 years ago

I'm getting same issue on a brand new app. Something isn't fixed here

ranjeshj commented 4 years ago

@FrancoisM You need to add XamlControlsResources to your app.xaml file. See details here.

@crutkas Can you check your App.xaml as well ?

crutkas commented 4 years ago

Yup, that is, this really needs to be a better runtime check. Super easy to miss.

crutkas commented 4 years ago

The bug that this was dup'ed against also doesn't have a clear "this is how you fix it" too.

ranjeshj commented 4 years ago

When you add the nuget package, it currently shows a readme with exactly the steps needed to avoid this. One thing to note that this will be a non-issue in WinUI3 where you will not have to do this extra step.