title: Loading XAML to C# for Data Binding
body: <p>Ok, we are trying out XAML for our GUI now (and learning as we go)...I have been able to do the data binding without a problem in XAML and C# independent of one another, but now comes the time I need to pass values back and forth and I'm a bit lost. When I compile and try to navigate to the page, it is throwing a XamlParseException: Specified class name doesn't match actual root instance type. Remove Class directive or provide an instance via XamlObjectWriterSettings.RootObjectInstance. Line 5 position 2.</p>
  
  <p>Any help or a gentle shove in the right direction is greatly appreciated :)</p>
  
  <p>Here's where I am:</p>
  
  <pre><code>namespace TheAirline.GraphicsModel.PageModel.PageFinancesModel
  {
      /// &lt;summary&gt;
      /// Interaction logic for PageFinances.xaml
      /// &lt;/summary&gt;
      public partial class PageFinances : Page
      {
          private Airline Airline;
  
          public PageFinances(Airline airline)
          {
              InitializeComponent();
              this.Language = XmlLanguage.GetLanguage(new   CultureInfo(AppSettings.GetInstance().getLanguage().CultureInfo, true).IetfLanguageTag);
  
              this.Airline = airline;
              Page page = null;
  //loading the XAML
            using (FileStream fs = new FileStream("TheAirline\\GraphicsModel\\PageModel  \\PageFinancesModel\\PageFinances.xaml", FileMode.Open, FileAccess.Read))
              {
              page = (Page)XamlReader.Load(fs);
              }
  //finding XAML element and trying to set the value to a variable
            string airlineCash = GameObject.GetInstance().HumanAirline.Money.ToString();
            TextBox cashValue = (TextBox)page.FindName("cashValue");
            cashValue.DataContext = airlineCash;
          }
      }
  }
  </code></pre>
  
  <p>And the first few lines of the XAML:</p>
  
  <pre><code>&lt;Page
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"      
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
      xmlns:AirlineModel="clr-namespace:TheAirline.Model.AirlineModel"
      mc:Ignorable="d"
  x:Class="TheAirline.GraphicsModel.PageModel.PageFinancesModel.PageFinances"
      xmlns:c="clr-namespace:TheAirline.GraphicsModel.Converters"
  ...&gt;
  &lt;/Page&gt;
  </code></pre>