title: Xamarin Forms access to all viewmodels
body: <p>I use ViewModelLocator in my project.</p>
  
  <p>I do BindingContent of ViewModelLocator in ResourceDictionary inside an app.xaml</p>
  
  <p>My codes:</p>
  
  <p><strong>App.xaml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Application xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
               xmlns:controlsHelpers="clr-namespace:MyProj.Source.Helpers.UIHelper.ControlsHelpers;assembly=MyProj"
               xmlns:configuration="clr-namespace:MyProj.Source.Configuration;assembly=MyProj"
               x:Class="MyProj.App"&gt;
    &lt;Application.Resources&gt;
  
      &lt;ResourceDictionary&gt;
        &lt;configuration:ViewModelLocator x:Key="ViewModelLocator"/&gt;
        &lt;/ResourceDictionary&gt;
    &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p><strong>ViewModelLocator.cs</strong> </p>
  
  <pre><code> public class ViewModelLocator
   {
          public LoginViewModel LoginViewModel { get; set; }
          public SignUpViewModel SignUpViewModel { get; set; }
  
  
          public ViewModelLocator()
          {
              LoginViewModel = new LoginViewModel();
              SignUpViewModel = new SignUpViewModel();
          }
   }
  </code></pre>
  
  <p><strong>LoginViewModel.cs</strong></p>
  
  <pre><code>public class LoginViewModel : AbstractViewModel
  {
  
          private MyModel UserData { get; set; } = new MyModel();
  
  
          private bool _isSignRequired;
  
  
          public bool IsSignRequired
          {
              get { return _isSignRequired; }
              set
              {
                  if (value == _isSignRequired) return;
                  _isSignRequired = value;
                  OnPropertyChanged();
              }
          }
  
          public string UserName
          {
              get { return UserData.UserName; }
              set
              {
                  if (value == UserData.UserName) return;
                  UserData.UserName = value;
                  OnPropertyChanged();
              }
          }
  
          public string Password
          {
              get { return UserData.Password; }
              set
              {
                  if (value == UserData.Password) return;
                  UserData.Password = value;
                  OnPropertyChanged();
              }
          }
  
  }
  </code></pre>
  
  <p><strong>SignUpViewModel.cs</strong></p>
  
  <pre><code>public class SignUpViewModel : AbstractViewModel
  {    
          private string _checkUserResultImage;
  
          public MyModel UserData { get; set; } = new MyModel();
  
          public string Phone
          {
              get { return UserData.Phone; }
              set
              {
                  if (UserData.Phone != null &amp;&amp; value == UserData.Phone) return;
                  UserData.Phone = value;
                  OnPropertyChanged();
              }
          }
  
          public string UserName
          {
              get { return UserData.UserName; }
              set
              {
                  if (UserData.UserName != null &amp;&amp; value == UserData.UserName) return;
                  UserData.UserName = value;
                  OnPropertyChanged();
              }
          }
  
          public string Password
          {
              get { return UserData.Password; }
              set
              {
                  if (UserData.Password != null &amp;&amp; value == UserData.Password) return;
                  UserData.Password = value;
                  OnPropertyChanged();
              }
          }
  
          public string Email
          {
              get { return UserData.Email; }
  
              set
              {
                  if (UserData.Email != null &amp;&amp; value == UserData.Email) return;
                  UserData.Email = value;
                  OnPropertyChanged();
              }
          }
  
          public string CheckUserResultImage
          {
              get { return _checkUserResultImage; }
              set
              {
                  if (value == _checkUserResultImage) return;
                  _checkUserResultImage = value;
                      OnPropertyChanged();
              }
          }
  
  
          public Command SignUpCommand
          {
             get
             {
                 return new Command(async () =&gt;
                 {
                     //Here I want to get data field from LoginViewModel
  
  
                 });
             }
          }
  }
  </code></pre>
  
  <p>I want to get data from LoginViewModel in SignUpViewModel.</p>
  
  <p>How can I do it? </p>