相关疑难解决方法(0)

在XAML中的WPF本地化,这样做的简单,简单和优雅的方式是什么?

我有一个很常见的问题.在WPF应用程序中进行本地化的最佳方法是什么.好吧,我在SO和Binged中搜索了很多.但我找不到任何非常简单和优雅的指针.

假设我必须在UI中显示如下内容:

英语:Orgnanization - Beoing

法语:Organizzazione - Beoing

    <StackPanel Orientation="Horizontal">
        <TextBlock Text="Organization -"></TextBlock>
        <TextBlock Text="{Binding Path=OrganizationName}">
        </TextBlock>
    </StackPanel>
Run Code Online (Sandbox Code Playgroud)

基本上,我需要将本地化文本分配给Organization Label TextBlock.我应该将连字符与"组织 - "分开并将其放在单独的标签中吗?

我怎么做?

.net wpf xaml localization

13
推荐指数
2
解决办法
9821
查看次数

WPF:如何在运行时更改CurrentUICulture

我正在尝试更改我的WPF应用在单击事件中使用的语言,但它不会更改.

private void menuItemGerman_Click(object sender, RoutedEventArgs e)
{
   Settings.Default.Culture = "de-DE";

   Thread.CurrentThread.CurrentCulture = new CultureInfo(Settings.Default.Culture);
   Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Culture);
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

.net c# vb.net wpf

12
推荐指数
1
解决办法
2万
查看次数

我如何动态切换不同的语言资源文件?

在我的wpf项目中,我添加了两个资源文件:

Resources\English.resx and Resources\German.resx
Run Code Online (Sandbox Code Playgroud)

在MainWindow.xml中,我尝试从资源文件中查找值:

<Window x:Uid="Window_1" x:Class="LocalizationInvestigate.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Resources="clr-namespace:LocalizationInvestigate.Resources"
        Title="MainWindow" Height="350" Width="525">
    <Grid x:Uid="Grid_1">
        <Label x:Uid="Label_1" Content="{x:Static Resources:English.LabelHello}"></Label>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

对于英语,它以这种方式完美地运作.但是,基于本地语言,我如何使用以下内容自动切换到德语:资源:German.LabelHello?

wpf localization

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

wpf ×3

.net ×2

localization ×2

c# ×1

vb.net ×1

xaml ×1