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.
在Resources/Icon.xaml 定义资源字典,则在app.xaml添加
<Application.Resources>
<ResourceDictionary Source="Resources/Icon.xaml" />
</Application.Resources>