title: Pass Value through Data Binding to Code-Behind WPF/C#
body: <p>I am currently working on a chess game and I am trying to connect the C# code-behind to the WPF interface in XAML. To represent the chess board, I have created an 8x8 uniform grid. 
  I want to pass the name of the square (cell of the grid) to the code behind and then have a method return the path of the image of the appropriate piece. For example, if there is a white rook on the square a8, this will be saved in the code-behind. In the xaml, each square will pass its name (e.g. 'a8') and receive the path to the image of the white rook. If there is no piece on the square, the path will link to a transparent image. This is what I have got so far: </p>
  
  <pre><code>&lt;StackPanel Height="auto" Width="auto" Orientation="Vertical" Margin="-5,0,5,0" &gt;
      &lt;UniformGrid  Rows="8" Columns="8" Background="Black" Height="800" Width="800"  HorizontalAlignment="Stretch"&gt;
          &lt;StackPanel Orientation="Vertical" Margin="1,1,1,1"&gt;
              &lt;Image Source="Resources/WhiteSquare.png"/&gt;
              &lt;Image Source=""/&gt;
              &lt;!--{Bind path to method in code-behind; pass name (e.g. a8); function then returns path to appropriate image of piece--&gt;
          &lt;/StackPanel&gt;
      &lt;/UniformGrid&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>I would appreciate some inspiration both for my xaml and c#. Thank you!</p>