title: Xamarin.Forms Localization
body: <p>Based on the solution on <a href="https://github.com/PieEatingNinjas/XamarinFormsLocalization" rel="nofollow noreferrer">github</a>, I want to add multilanguage to my solution.
  However, I have my codebehind, and not XAML, so I don't know how to do TwoWay Binding in codebehind.</p>
  
  <p>Here is the xaml class which I want to convert to codebehind:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
           x:Class="myProj.Forms.Pages.LanguageSettingsPage"
           Title="{Binding Resources[Settings]}"&gt;
  &lt;StackLayout&gt;
      &lt;Label Text="{Binding Resources[PickLng]}" /&gt;
      &lt;Picker ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage, Mode=TwoWay}" /&gt;
  &lt;/StackLayout&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p>and now my codebehind looks like:</p>
  
  <pre><code>[XamlCompilation(XamlCompilationOptions.Compile)]
  public partial class LanguageSettingsPage : ContentPage
  {
      public LanguageSettingsPage()
      {
          BindingContext = new SettingsViewModel();
          //InitializeComponent();
  
          StackLayout mainStack = new StackLayout();
          mainStack.BackgroundColor = Constants.iBackgroundGray;
          Label chooseLangLabel = new Label { TextColor = Constants.iGray };
          chooseLangLabel.Text = LocalizationDemoResources.PickLng;
          Picker langPicker = new Picker();
          langPicker.SelectedItem = App.CurrentLanguage;
          mainStack.Children.Add(chooseLangLabel);
          mainStack.Children.Add(langPicker);
          Content = mainStack;
      }
  }
  </code></pre>
  
  <p>And my SettingsViewModel:</p>
  
  <pre><code> public class SettingsViewModel : ViewModelBase
  {
      public List&lt;string&gt; Languages { get; set; } = new List&lt;string&gt;()
      {
          "EN",
          "NL",
          "FR"
      };
  
      private string _SelectedLanguage;
      public string SelectedLanguage
      {
          get { return _SelectedLanguage; }
          set
          {
              _SelectedLanguage = value;
              SetLanguage();
          }
      }
  
      public SettingsViewModel()
      {
          _SelectedLanguage = App.CurrentLanguage;
      }
  
      private void SetLanguage()
      {
          App.CurrentLanguage = SelectedLanguage;
          MessagingCenter.Send&lt;object, CultureChangedMessage&gt;(this,
                  string.Empty, new CultureChangedMessage(SelectedLanguage));
      }
  }
  </code></pre>
  
  <p>My folder with resource files looks like </p>
  
  <p><a href="https://i.stack.imgur.com/zBAYM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBAYM.png" alt="this"></a></p>
  
  <p>How to bind it, to get picker filled with values from my suffixes resource files?
  And how to be observable or somewhat, to be able to change languages on click of an item in picker?</p>
  
  <p>Thanks.</p>