WPF ListBox ItemsSource with DataTemplate

datatemplateitemssourcelistboxwpf

I have a ListBox with an ItemsSource pointing to a static variable, and a DataTemplate for the ListBox's ItemTemplate that should be displaying the Description property of the variable the ItemsSource points to

<ListBox x:Name="classificationTypeListBox"
   ItemsSource="{x:Static h:AmbientHighlightingStyleRegistry.Instance}" 
   SelectedIndex="0" Foreground="Black">
  <ListBox.ItemTemplate>
    <DataTemplate>
      <TextBlock Text="{Binding Path=(Description)}" />
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

I can put a break point on my application and view the ListBox. The ItemsSource does point to the variable I want and it looks like the ListBox is trying to display all the values because I can click and scroll down the it. However, no text is getting displayed so you can't actually tell what you're clicking. Also, while the break point is on, it says that the list box contains 0 items, maybe it should because I'm binding it, not sure. Any suggestions?

Best Answer

<TextBlock Text="{Binding Path=(Description)}" />

Why do you have parens in there? This syntax causes WPF to try to bind to an attached property, which is not what you want to do.