title: Xamarin forms - Passing data between pages & views
body: <p>I have a xamarin forms app. 
  There are 2 classes with data, one of the pages is filling the data.</p>
  
  <p>The problem is: I'm creating new view, that should use data from both classes.</p>
  
  <p>The only way i'm familiar with is to set a class as a <code>bindingContext</code> to pass data between pages, and it's working fine with <strong>ONE</strong> class, because apparently there couldn't be <code>2 bindingContext</code> at the same time.</p>
  
  <p>EXAMPLE:</p>
  
  <p>1st class (all the classes are filled on the previous page. just accept that they are filled)</p>
  
  <pre><code>public class Buildings : INotifyPropertyChanged
      {
          public event PropertyChangedEventHandler PropertyChanged;
  
          private string _id;
  
          public string Id
          {
              get { return _id; }
              set
              {
                  _id = value;
                  PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Id"));
              }
          }
  }
  </code></pre>
  
  <p>2nd class </p>
  
  <pre><code>public class Flats : INotifyPropertyChanged
          {
              public event PropertyChangedEventHandler PropertyChanged;
  
              private string _num;
  
              public string Num
              {
                  get { return _num; }
                  set
                  {
                      _num = value;
                      PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Num"));
                  }
              }
      }
  </code></pre>
  
  <p>new view: </p>
  
  <pre><code>public partial class HouseView
      {
          private Flats _flats;
          private Buildings _buildings;
          public HouseView()
          {
              InitializeComponent();
          }
  
          private void HouseView_OnBindingContextChanged(object sender, EventArgs e)
          {
              var building = BindingContext as Building;
              //var flat = BindingContext as Flat;
              //_flat = flat;
              _building = building;
             var buildingInfo = await Rest.GetHouseInfo(_building.Id, _flat.Num); //function that will return info on a current house;
            // rest code
          }
      }
  </code></pre>
  
  <p>Maybe there is no need for binding context, because i'm just passing the parameters, not changing them in a view? I guess the solution can be pretty simple, and i cant figure it out....</p>