I am recieving following error in VS 2010.
I have two Silverlight projects. one project only contains styles
and other project i开发者_Go百科s my application. I have referenced styles project in my application and user static resources from that project in my whole application, but I keep recieving this error in VS though everything works fine when I compile and run the application.
The resource "SearchBoxStyle" could not be resolved
Yes, I stumped on this one today and I am also looking for a solution.
It seems to be a missing feature of Visual Studio - VS XAML designer just cannot find static resources outside of the current XAML file. It seems, Expression Blend is smarter and offers a workaround for such cases.
Here is a similar thread which suggests using Blend: The resource could not be resolved (VS 2010 RC)
And here is what Microsoft says about this issue: http://msdn.microsoft.com/en-us/library/bb546934(VS.90).aspx#ResourcesatDesignTime
And for me the solution was to put a / in the path of my resource and set the xaml file to compile as a resource. So my App.xaml looks like this:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/ControlStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Dummy Style for WPF 4 bug fix, anything you won't use goes -->
<Style TargetType="{x:Type WebBrowser}" />
</ResourceDictionary>
</Application.Resources>
It failed to load at design time when I did not use the first slash in the path, but now it works fine at design time in other XAML pages.
精彩评论