WPF Application Implement Multilingual in VB.NET

In this article you will found the simplest way to implement Multilingual WPF Application to handle Globalization.
  • 3307
 

Creating a multilingual application using WPF is a very common issue to everyone. This is the easiest way to handle Globalization in the WPF Application. While creating an application, it is quite natural to create an application that has Multilingual Support.  In this article, I am going to discuss how to implement a multilingual application. 

Code to Implement Multilingual WPF Application

<Window x:Class="WPFGlobalization.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Sample Application" 
    WindowState="Normal" 
    WindowStyle="ThreeDBorderWindow" 
    Loaded="Window_Loaded">
        <Window.Resources>
       <ResourceDictionary Source="Styles\BlueThemeStyle.xaml"/>
    </Window.Resources>
    <Grid>
        <Canvas>
            <Canvas.Background>
                <ImageBrush ImageSource="{StaticResource winBackground}"Stretch="Fill"/>
            </Canvas.Background>
        </Canvas>
        <Border x:Name="brdrMain">
            <Border.Style>
                <Style TargetType="{x:Type Border}">
                    <Setter Property="CornerRadius" Value="10" />
                    <Setter Property="Margin" Value="100" />
                    <Setter Property="BorderThickness" Value="4" />
                    <Setter Property="BorderBrush" Value="{StaticResourceinfoBox_brush}" />
                </Style>
            </Border.Style>
            <!--<Border.Effect>
            </Border.Effect>-->
            <Border.Effect>
                <DropShadowEffect ShadowDepth="7"
                                  Color="#FFF4BA9A"
                                  BlurRadius="15"></DropShadowEffect>
            </Border.Effect>
            <Grid x:Name="grdLogin" Margin="15"
                  HorizontalAlignment="Center"
                  VerticalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="200"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Text="{DynamicResource UserName}" 
                           Grid.Row="0" 
                           Grid.Column="0" 
                           Padding="10"/>
                <TextBlock Text="{DynamicResource Password}"
                           Grid.Row="1"
                           Grid.Column="0"
                           Padding="10" />
                <TextBlock Text ="{DynamicResource Language}"
                           Grid.Row="2"
                           Grid.Column="0" 
                           Padding="10" />
                <PasswordBox x:Name="txtPassword"
                             Grid.Row="1"
                             Grid.Column="1" 
                             MinHeight="5"
                             Margin="10" />
                <TextBox x:Name="txtUserName"
                         Grid.Row="0"
                         Grid.Column="1" 
                         MinHeight="5"
                         Margin="10" />
                <TextBlock x:Name="tbLanguage"
                         Grid.Row="2"
                         Grid.Column="1"
                         MinHeight="5"
                         Margin="10" />
                <Button x:Name="btnLogin"
                        Click="btnLogin_Click"
                        Content="{DynamicResource login}"
                        Grid.Row="3"
                        Grid.Column="0" 
                        Padding="10" />
                <Button Name="btnClose"
                        Content="{DynamicResource close}"
                        Click="btnClose_Click"
                        Grid.Row="3"
                        Grid.Column="1" 
                        Padding="10" />
            </Grid>
        </Border>
    </Grid>
</
Window>

Output Window

Globalization1.gif

Now if you put Username and Password , and press Login button you will see the window below:

Globalization2.gif


To change the language, go to Control Panel and select Regional & Language Option and change the language as below:

Globalization3.gif

Conclusion 

Multilingual application is the most common issue in Globalization, I hope this article will help you in long run.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.