好的,所以這個原型的總體目標是在C#中使用WPF創建一個GUI窗口,允許用戶從菜單中更改語言。目前我正嘗試使用App.config文件將窗口的某些組件從英語切換到德語。我知道這不會允許資產使用按鈕進行更改,但這是一個開始。XAML C#本地化問題
我有3個資源文件。一個是默認(英文),另一個是英文,標爲en-US,最後一個是德語,標註爲de-DE。他們都是公共的。
我已經使用了這些兩個視頻作爲引導線:
http://www.youtube.com/watch?v=5MuN6VOw9r4
http://www.youtube.com/watch?v=BK7jp3snwCQ
予設定的標籤的在XAML
部分中的內容和兩個按鈕:
<Label Content="{x:Static properties:Resources.Label1}" Height="28" Margin="6,6,79,0" Name="Label1" VerticalAlignment="Top"></Label>
<Button Content="{x:Static properties:Resources.Button1}" Height="23" HorizontalAlignment="Left" Margin="6,40,0,0" Name="Button1" VerticalAlignment="Top" Width="75"></Button>
<Button Content="{x:Static properties:Resources.Button2}" Height="23" HorizontalAlignment="Left" Margin="6,69,0,0" Name="Button2" VerticalAlignment="Top" Width="75"></Button>
這是我在我的App.config文件(de-DE)中應該將編輯的內容更改爲德語:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Culture" value="de-DE" />
</appSettings>
</configuration>
最後,我xaml.cs文件中有以下內容:
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Globalization;
using System.Configuration;
namespace WPF_Prototype1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
/// This line should allow the program to read the App.config file!
Properties.Resources.Culture = new CultureInfo(ConfigurationManager.AppSettings["Culture"]);
}
}
}
爲什麼我的程序仍然沒有改變這些圖標的德國人?我能做些什麼來解決它?
謝謝
如果移動線,以你的App.xaml.cs啓動下,這是否能改變什麼? – user7116
不,我在嘗試使用'CultureInfo'和'「文化」' –