WPF Localization in XAML, what is the simple, easy and elegant way of doing it?

后端 未结 5 1154
既然无缘
既然无缘 2021-02-07 10:14

I have a very common question. What is the best way to do localization in a WPF app. Well, I searched in SO and Binged a lot too. But I could not find any pointers which is real

5条回答
  •  独厮守ぢ
    2021-02-07 10:35

    Create a project WpfApplication1

    Create a folder 'Localization'

    Add a resource file (Strings.resx) in 'localization\' and add the string 'OrganizationText' and value 'Organisation'

    When you compile, a designer.cs file is generated. Unfortunatly, all methods in this file are internal and we need public acces to enable string references from wpf. To do that, replace the .resx 'custom tool' with 'PublicResXFileCodeGenerator' (>=vs2008) and build again. Use this xaml in MainWindow.xaml:

    
            
                
            
    
    

    To add the ' - ', you must use multibinding (see here)

提交回复
热议问题