Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Localization in WPF MVVM

Localization in WPF MVVM

Scheduled Pinned Locked Moved WPF
wpfcsharpwcfarchitecturehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sifi mohamed amine
    wrote on last edited by
    #1

    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 :

    <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 :

    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

    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));
           
    
    
        });
    
    V 1 Reply Last reply
    0
    • S sifi mohamed amine

      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 :

      <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 :

      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

      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));
             
      
      
          });
      
      V Offline
      V Offline
      Vincent Beek
      wrote on last edited by
      #2

      Where is your SelectedLanguage property declaration? What does it look like?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups