title: How do you handle Linq to SQL Foreign Key relationships in WPF DataBinding
body: <p>I have been fighting this issue for some time so today I started a new project and simplified things to the basics. What I want to do is have a listbox, bound to a collection with a detail view of the selected item shown below. It all works fine except the items that refer to other tables simply show the foreign key. I was able to resolve this with a linq query but realize that the method I used is hackish. </p>
  
  <pre><code>public partial class Window1 : Window
  {
      DataClasses1DataContext db = new DataClasses1DataContext();
      public IEnumerable&lt;Issue&gt; issues = null;
  
      public Window1()
      {
          InitializeComponent();
          issues = from i in db.Issues
                   select i;
          this.DataContext = issues;
      }
  
      // The hacked in query that correctly displays the name instead of Key
      private void IssueListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          List&lt;Issue&gt; _issues = issues.ToList();
          int empl = _issues[IssueListBox.SelectedIndex].IssOwner;
  
          OwnerTextBlock.Text = (from emp in db.Employees
                                where emp.EmpID == empl
                                select emp.EmpFirstName.ToString() + " " + 
                                         emp.EmpLastName.ToString()).Single();            
      }
  }
  </code></pre>
  
  <p>The Xaml as simple as I could get it:</p>
  
  <p></p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;DataTemplate x:Key="ShowIssueDetail"&gt;
          &lt;TextBlock Text="{Binding Path=IssTitle}" FontWeight="Bold" FontSize="14"/&gt;
      &lt;/DataTemplate&gt;
  &lt;/Window.Resources&gt;
  
      &lt;StackPanel&gt;
      &lt;TextBlock Text="Issues" FontWeight="Bold" /&gt;
      &lt;ListBox x:Name="IssueListBox"
                ItemsSource="{Binding}"
                ItemTemplate="{StaticResource ShowIssueDetail}"
                IsSynchronizedWithCurrentItem="True"
                HorizontalContentAlignment="Stretch" SelectionChanged="IssueListBox_SelectionChanged"&gt;
      &lt;/ListBox&gt;
  
      &lt;TextBlock Text="{Binding Path=IssDescription}" /&gt;
      &lt;TextBlock Text="{Binding Path=IssOwner}" /&gt; &lt;!--I want this to show the name, not the Key--&gt;
      &lt;TextBlock Name='OwnerTextBlock' /&gt; &lt;!--This has the name set in code from the Linq query and works--&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p></p>
  
  <p>How do I do this correctly?</p>