title: C# variable in XAML code
body: <p>I have a partial class code behind for a XAML form.  Here is the code behind:</p>
  
  <pre><code>partial class GalleryDictionary
  {
      private void GalleryItemLabelPropertyChanged(object sender, RoutedEventArgs e)
      {
          var mainWindow = Application.Current.MainWindow as MainWindow;
          if (mainWindow == null)
              return; 
  
          var tb = sender as TextBox;
          if (tb == null)
              return;
  
          var sip = tb.DataContext as StereoImagePair;
          if (sip == null)
              return;
  
          sip.Label = tb.Text;
  
          mainWindow.Db.SubmitChanges();
      }
  }
  </code></pre>
  
  <p>That is the entire DOC.XAML.CS file after the namespace declaration.</p>
  
  <p>In my XAML file I need to access a variable from this XAML.CS file that I'd like to call DriveOnRight.  Here is the line I've been fighting:</p>
  
  <pre><code>        &lt;ToggleButton Grid.Row="1" Grid.Column="2" Width="26" Height="26" IsChecked="True" Click="GalleryItemLabelPropertyChanged" CommandParameter="2" Name="PS" Content="{Binding DriveOnRight}"&gt;&lt;/ToggleButton&gt;
  </code></pre>
  
  <p>Where the XAML file reads....Content="{Binding DriveOnRight}" is where I need to access the variable from the CS file and display it there.  </p>
  
  <p>How do I do that?  </p>
  
  <p>Any help sure will be appreciated.</p>