'System.Windows.StaticResourceExtension' threw an exception

As a work around for this issue I moved all styles defined in App.xaml to another Resource dictionary file (say GenericThemes.xaml ) , and included that resource dictionary in app.xaml as below
<Application.Resources>
        <ResourceDictionary Source="GenericThemes.xaml" />
</Application.Resources>

The styles defined in GenericThemes.xaml are now available across the application without any extra changes and without this exception.

http://connect.microsoft.com/VisualStudio/feedback/details/568346/wpf-error-message-when-there-is-a-style-only-in-app-xaml-and-application-onstartup-is-overridden

在Resources/Icon.xaml 定义资源字典,则在app.xaml添加

<Application.Resources>
        <ResourceDictionary Source="Resources/Icon.xaml" />
</Application.Resources>

原文地址:https://www.cnblogs.com/wangchunming/p/2508555.html