title: Apply multiple Datatemplates to listbox Itemtemplate based on data
body: <p>I'm sure this is simple but i just cant seem to figure out how to do it. Basicly i have a list of customers that comes from a azure mobile service database. so far everything works fine but I would like to set the item template for each item in a listbox based on the data. I have 2 templates, one for companies and on for just a person. My question is how to apply each one.</p>
  
  <p>Templates</p>
  
  <pre><code>&lt;DataTemplate x:Key="CompanyItemTemplate"&gt;
      -------
  &lt;/DataTemplate&gt;
  
  &lt;DataTemplate x:Key="CustomerItemTemplate"&gt;
      -------
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>CustomerListItems.ItemsSource = customeritems.OrderBy(customer =&gt; customer.CustomerName);
  
  foreach (Customers customer in customeritems)
  {
      if (customer.Company != "")
      {
          CustomerListItems.ItemTemplate = CompanyItemTemplate;
      }
      else
      {
          CustomerListItems.ItemTemplate = CustomerItemTemplate;
      }
  }
  </code></pre>