title: Xamarin local variable in xaml.cs and printing through the XAML file
body: <p>I want to be able to print properties from 'CurrentOrder' in the XAML.</p>
  
  <p>Here is what I have so far: </p>
  
  <pre><code>// OrderPage.xaml.cs
  public partial class OrderPage : ContentPage
  {
      private Order _currentOrder;
  
      public Order CurrentOrder
      {
          get { return _currentOrder; }
      }
  
      public OrderPage()
      {
          InitializeComponent();
  
          _currentOrder = Order.DefaultOrder;
  
          addPin("Start", _currentOrder.PickupAddress.Latitude, _currentOrder.PickupAddress.Longitude);
          addPin("End", _currentOrder.DropoffAddress.Latitude, _currentOrder.DropoffAddress.Longitude);
  
          this.BindingContext = this;
      }
  
      public OrderPage(Order order)
      {
          InitializeComponent();
  
          _currentOrder = order;
  
          addPin("Start", _currentOrder.PickupAddress.Latitude, _currentOrder.PickupAddress.Longitude);
          addPin("End", _currentOrder.DropoffAddress.Latitude, _currentOrder.DropoffAddress.Longitude);
  
          Debug.WriteLine(_currentOrder.ToString());
  
          this.BindingContext = this;
      }
  }
  </code></pre>
  
  <p>Here is the Order class, which has several properties with other classes.</p>
  
  <pre><code>public class Order : INotifyPropertyChanged
  {
      public static Order DefaultOrder
      {
          // I have a default order return here, but in the sake of privacy, I'm removing my test addresses 
      }
  
      // event to handle changes in the order status 
      public event PropertyChangedEventHandler PropertyChanged;
  
      public enum Status { Preview, NeedsDriver, WaitingDriver, InTransit, NeedsSignature, Complete, Refunded }
  
      public string ID { get; set; }
      public string Description { get; set; }
      private Status _orderStatus;
      public Status OrderStatus { 
          get
          {
              return _orderStatus;
          }
          set
          {
              _orderStatus = value;
              // tell the view that the order status has changed 
              OnPropertyChanged("OrderStatus");
          }
      }
      public Contact PickupContact { get; set; }
      public Contact DropoffContact { get; set; }
      public Address PickupAddress { get; set; }
      public Address DropoffAddress { get; set; }
      public DateTime PickupTime { get; set; }
      public DateTime DropoffTime { get; set; }
  
      // Formatted Pickup and Dropoff Times
      public string PickupTimeFormatted
      {
          get { return PickupTime.ToString("g"); }
      }
      public string DropoffTimeFormatted
      {
          get { return DropoffTime.ToString("g"); }
      }
  
      public Order()
      {
      }
  
      // Handler to tell the view that the order status has changed 
      protected void OnPropertyChanged(string name)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
          if (handler != null)
          {
              handler(this, new PropertyChangedEventArgs(name));
          }
      }
  
      public override string ToString()
      {
          return string.Format("[Order: ID={0}, Description={1}, OrderStatus={2}, PickupContact={3}, DropoffContact={4}, PickupAddress={5}, DropoffAddress={6}, PickupTime={7}, DropoffTime={8}, PickupTimeFormatted={9}, DropoffTimeFormatted={10}]", ID, Description, OrderStatus, PickupContact, DropoffContact, PickupAddress, DropoffAddress, PickupTime, DropoffTime, PickupTimeFormatted, DropoffTimeFormatted);
      }
  }
  </code></pre>
  
  <p>Finally, the XAML.</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" 
      xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
      x:Class="Divco.OrderPage"
      Title="Order"&gt;
  &lt;ContentPage.BindingContext&gt;
  &lt;/ContentPage.BindingContext&gt;
  &lt;ContentPage.Content&gt;
      &lt;StackLayout Spacing="10" x:Name="layout" VerticalOptions="FillAndExpand"&gt;
          &lt;StackLayout&gt;
              &lt;maps:Map WidthRequest="320"
                        HeightRequest="150"
                        x:Name="MyMap"
                        IsShowingUser="false"
                        MapType="Street" /&gt;
          &lt;/StackLayout&gt;
          &lt;StackLayout Padding="20, 20, 20, 0"&gt;
              &lt;!--&lt;Label Content="{Binding ID, Source={StaticResource CurrentOrder}}"&gt;&lt;/Label&gt;--&gt;
              &lt;Label Text="{Binding ID}"
                     TextColor="Fuchsia" /&gt;
              &lt;Label Text="Description"
                     LineBreakMode="WordWrap" /&gt;
          &lt;/StackLayout&gt;
          &lt;StackLayout Padding="20, 20, 20, 0"&gt;
              &lt;Grid&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition Height="*" /&gt;
                      &lt;RowDefinition Height="*" /&gt;
                  &lt;/Grid.RowDefinitions&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="*" /&gt;
                      &lt;ColumnDefinition Width="*" /&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Label Text="Pickup"
                         Grid.Row="0"
                         Grid.Column="0"
                         Grid.ColumnSpan="2"
                         TextColor="Fuchsia"/&gt;
                  &lt;Label Text="Top Left"
                         Grid.Row="1"
                         Grid.Column="0" /&gt;
                  &lt;Label Text="Top Right"
                         Grid.Row="1"
                         Grid.Column="1" /&gt;
                  &lt;Label Text="Dropoff"
                         Grid.Row="2"
                         Grid.Column="0"
                         Grid.ColumnSpan="2"
                         TextColor="Fuchsia"/&gt;
                  &lt;Label Text="Bottom Left"
                         Grid.Row="3"
                         Grid.Column="0" /&gt;
                  &lt;Label Text="Bottom Right"
                         Grid.Row="3"
                         Grid.Column="1" /&gt;
              &lt;/Grid&gt;
          &lt;/StackLayout&gt;
          &lt;StackLayout Padding="20, 20, 20, 20" VerticalOptions="EndAndExpand"&gt;
              &lt;Grid&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition Height="*" /&gt;
                  &lt;/Grid.RowDefinitions&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="*" /&gt;
                      &lt;ColumnDefinition Width="*" /&gt;
                      &lt;ColumnDefinition Width="*" /&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Button Text="Call X" 
                          BackgroundColor="Fuschia" 
                          TextColor="White" 
                          Grid.Row="0"
                          Grid.Column="0"/&gt;
                  &lt;Button Text="Navigate!" 
                          BackgroundColor="Fuschia" 
                          TextColor="White" 
                          Grid.Row="0"
                          Grid.Column="1"
                          Grid.ColumnSpan="2"/&gt;
              &lt;/Grid&gt;
          &lt;/StackLayout&gt;
      &lt;/StackLayout&gt;
  &lt;/ContentPage.Content&gt;
  </code></pre>
  
  <p></p>
  
  <p>You can see where I attempted to print the ID of the order in the XAML. All of the supporting classes for the Order have ToString(s) which return the needed information for the order page, so I'm not really worried about printing '_currentOrder.PickupAddress.Address1', for example. </p>