[英]Visual Studio 2012 XAML designer does not show correct content when App.xaml in different assembly
我正在將VSF中的WPF應用程序移動到VS 2012。
我有一個主要的可執行文件,其中包含App.xaml和一個單獨的類庫,用於所有WPF內容。 在VS2012(SP3)中,XAML設計器沒有顯示在App.xaml中定義的MergedResourceDictionary中的任何樣式,VS 2010確實......
出於測試目的,我將App.xaml移動到了我的類庫。 之后,VS 2012設計師正確地展示了一切。
由於類庫不能包含App.xaml,因此這不是一個解決方案。
有任何想法嗎?
我的App.xaml如下所示:
<Application x:Class="MyApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Startup="AppStartup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/OtherAssemblyName;component/Resources/Resource1.xaml" />
<ResourceDictionary Source="pack://application:,,,/OtherAssemblyName;component/Resources/Resource2.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
知道這是一個老問題,但是對於任何可能在將來面臨類似事情的人來說都要回答它。
最安全的方法是創建一個新的ResourceDictionary文件,並在其中添加MergedResourceDictionaries。
然后在你的用戶控件/ pages / windows中引用ResourceDictionary - 所有這些,因為
<UserControl.Resources>
<ResourceDictionary Source="GlobalResources.xaml" />
<UserControl.Resources>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.