这是我的问题:
我有多语言WPF应用程序,资源在两个不同的文件中。现在我在app.xaml中选择正确的一个。cs类似:
var dict = new ResourceDictionary();
switch (Thread.CurrentThread.CurrentCulture.ToString())
{
case "de-DE":
dict.Source = new Uri("pack://application:,,,/Resources;component/StringResources.de-DE.xaml", UriKind.Absolute);
break;
default:
dict.Source = new Uri("pack://application:,,,/Resources;component/StringResources.xaml", UriKind.Absolute);
break;
}
Resources.MergedDictionaries.Add(dict);
一切都很好,但我在VisualStudioDesigner中看不到这些资源。
另一方面,当我在App中定义ResourceDictionary时。xaml文件如下:
<Application x:Class="Ampe.UI.Views.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Exit="App_OnExit" ShutdownMode="OnMainWindowClose">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Resources;component/StringResources.de-DE.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
然后我在设计器中有这些资源,但我不能设置多语言。
在多语言应用程序的设计器中是否可以看到资源?也许是某种改变应用。应用程序打开时xaml文件?