Click here to Skip to main content
16,021,823 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,
I need to change culture mainly between two languages ; italian and English using the Combobox in WPF MVVM.
I tried to databind the ViewModel with my Mainview but I didn't succeed.
I will be so thankful if someone could help.

Here is my Combobox declaration in xaml :
HTML
<ComboBox IsEditable="True" Text="Language" HorizontalAlignment="Right" VerticalAlignment="Top" Width="95"  Margin="34,21,34,0" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Foreground="#FF434C64" removed="Green" Height="24.96"  />


Here is View Model definition :

C#
public void ChangeLanguage()
         {
             if (SelectedLanguage == "en")
             {
                 Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");

             }
             else
             if (SelectedLanguage == "it-IT")
             {
                 Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT");
             }

         }



Here the declaration within the construcor of my View Model




C#
public ViewModel()
       {

           LoadData();
           ChangeLanguage();

           Login = new DelegateCommand(this.Logging, delegate()
           {
               return (!String.IsNullOrEmpty(Username) && !String.IsNullOrEmpty(Password) && !String.IsNullOrEmpty(Email));
           });
           Register = new DelegateCommand(this.Registering, delegate()
           {

          return (!String.IsNullOrEmpty(Username) && !String.IsNullOrEmpty(Password) && !String.IsNullOrEmpty(Email));



       });
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900