0
안녕하세요 저는 다국어 WPF Office 추가 기능을 만들 필요가 있습니다. 리소스 파일을 사용하고 싶습니다. 난 내 SetLanguageDictionary 내 ThisAddIn_Startup 함수 호출wpf에서 리소스 사전로드 응용 프로그램에서 추가
public static void SetLanguageDictionary()
{
try
{
//Get the assembly information
System.Reflection.Assembly assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly();
Uri uriCodeBase = new Uri(assemblyInfo.CodeBase);
string path = Path.GetDirectoryName(uriCodeBase.LocalPath.ToString());
ResourceDictionary dict = new ResourceDictionary();
switch (Thread.CurrentThread.CurrentCulture.ToString())
{
case "en-US":
dict.Source = new Uri(path + "\\Resources\\en-US.xaml",
UriKind.Absolute);
break;
case "fr-FR":
dict.Source = new Uri(path + "\\Resources\\fr-FR.xaml",
UriKind.Absolute);
break;
default:
dict.Source = new Uri(path + "\\Resources\\en-US.xaml",
UriKind.Absolute);
break;
}
Application.Current.Resources.MergedDictionaries.Add(dict);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
내 자원 파일이 거기
<ResourceDictionary
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="Ready">Ready</system:String>
<system:String x:Key="login">Login</system:String>
<!-- All StringResources Goes Here -->
</ResourceDictionary>
로드 내가 오류가있을 때 : 시스템 잘못된 연산 예외 : URI와 작동 오류 loadfrom의 resouceDictionary : "파일 : /// C : 답장을 보내
덕분에