locked
Restarting windows store application

    Question

  • Hello,

    I am trying to make demo for multilingual app. In that I have simple combobox with two language option "English" and "French".

    I have already created resource file for this two language. Now what I want is if user change the language I need to automatically reload app.

    This is the code that I am using right now on selectionchange event but its not updating the page.

              if (cbLanguage.SelectedIndex == 0)
                {
                    var culture = new CultureInfo("en-US");
    
                    Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
    
                    CultureInfo.DefaultThreadCurrentCulture = culture;
    
                    CultureInfo.DefaultThreadCurrentUICulture = culture;
                }
                if (cbLanguage.SelectedIndex == 1)
                {
                    var culture = new CultureInfo("fr-ch");
    
                    Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
    
                    CultureInfo.DefaultThreadCurrentCulture = culture;
    
                    CultureInfo.DefaultThreadCurrentUICulture = culture;
                }
                Frame.Navigate(typeof(MainPage));
    If I restart the app I can see the changes but I want that app automatically restart.

    Thanks in advance.

    • Edited by zee_patel Thursday, February 27, 2014 10:31 AM
    Thursday, February 27, 2014 10:29 AM

All replies

  • you cant restart your app. navigate again to the page will work too

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Thursday, February 27, 2014 10:33 AM
  • Hi Dave,

    As shown in my code snippet, I am already navigating to the page again but it is not changing the language on first time. I need to select the language from the combobox again.

    And how to restart app automatically?

    Thursday, February 27, 2014 10:41 AM
  • try to set the langauge of the frame:

           _rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

    it's not possible to restart your app, its something the user has to do


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Thursday, February 27, 2014 11:02 AM
  • Dave, I tried your code it changes the language of the frame, but its not updating the UI means text of the textblock is not changing its language, compulsory I need to restart my app manually. It create bad UX.

     Can you suggest me some good way to do that?




    • Edited by zee_patel Thursday, February 27, 2014 11:28 AM
    Thursday, February 27, 2014 11:27 AM