2

I am trying to debug this issue for last 2 days, I have tried all the solutions available on SO and Microsoft connect but can't seem to find any solution.

I downloaded the Windows Phone 8 sdk, installed and created a new project, but when I tried to edit App.xaml I got

XamlParseException: Cannot find a Resource with the Name/Key PhoneProgressBarBackgroundBrush [Line: 729 Position: 39] at at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers, Boolean expandTemplatesDuringParse, Boolean trimDeclaredEncoding) at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr& nativeStyle)

Please help me resolve this issue.

Undo
  • 25,519
  • 37
  • 106
  • 129
TilalHusain
  • 1,006
  • 5
  • 17
  • 36

2 Answers2

2

Had same issue, reinstalling WP8 SDK didn't help either.

The problem can be overcome by adding ThemeResources.xaml to the project resources as follows:

Blend: In project view, right click Resources folder and choose "Link to existing item...". Add C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Design\ThemeResources.xaml there and it should work.

VS2012: In Solution Explorer, right click folder "Resources" and choose "Add" -> "Existing item...". Navigate to C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Design\ThemeResources.xaml and choose "Add as link".

I've got no idea about the root cause i.e. why ThemeResources.xaml isn't included in the new project.

lirkki
  • 221
  • 1
  • 8
  • 1
    Edit by gerichhome : Also don't forget to manually add ThemeResources to App.xaml: ` ... ... ` You should also set `MSBuild:MarkupCompilePass1` custom tool property for a ThemeResources.xaml to enable some compile time checks. – StuartLC Nov 28 '12 at 10:00
  • @StuartLC , can you please explain a bit more, because when I add your code in app.xaml, I get "each dictionary should have a key" – TilalHusain Dec 06 '12 at 09:10
  • I pasted an *invalid* edit that @gerichhome attempted to make to JaniLirkki's post, as it may have some bearing on the answer. I'm afraid I have no expertise here :( – StuartLC Dec 06 '12 at 12:30
1

Did you search for PhoneProgressBarBackgroundBrush? It should show up in a Resource Dictionary. If you find it, I'd go make sure that Resource Dictionary is declared as a MergedDictionary in your app.xaml, if you can't find it, then you have the next troubleshooting question asked, as to whether it just needs added.

You can try putting something like this into a resource dictionary;

<SolidColorBrush x:Key="PhoneProgressBarBackgroundBrush"
                 x:Name="PhoneProgressBarBackgroundBrush"
                 Color="Black" />

If you're not sure of what file holds your other brushes, a quick search for something like "<solidcolorbrush" should show you others. Hope this helps.

Chris W.
  • 22,835
  • 3
  • 60
  • 94
  • I searched for PhoneProgressBarBackgroundBrush it is not showing anywhere in my project, what should I do in that case? – TilalHusain Nov 12 '12 at 07:38
  • 1
    Looks like there's a bit more to it I see according to the link. Did you try just creating a brush / adding it to a dictionary and naming it PhoneProgressBarBackgroundBrush so it can be found? http://connect.microsoft.com/VisualStudio/feedback/details/769302/in-wp8-sdk-i-created-an-app-and-do-nothing-for-this-app-but-the-mainpage-xaml-has-occoured-xamlparseexception – Chris W. Nov 12 '12 at 07:41
  • Sorry I am quite new with windows phone development, can you please tell me how can I do that, also this issue is only happening on one machine, rest are working fine. – TilalHusain Nov 12 '12 at 07:52