I need to be able to use a series of attributes as the source in a WPF list view. I'm currently stuck on how to do this. I know how to do it for XML nodes but not for attributes. Here's an example of what I'm trying to bind too:
<Stats HP="55000" MP="2500" SP="2500" Strength="212" Vitality="125" Magic="200" Spirit="162" Skill="111" Speed="109" Evasion="100" MgEvasion="100" Accuracy="100" Luck="55" />
I want each stat name/value to be an entry in the listview. Here's the code I've been trying to make work:
<TabControl.DataContext>
<Binding ElementName="EnemyLevelsListBox" Path="SelectedItem"/>
</TabControl.DataContext>
<TabItem Header="Stats" Name="EnemyStatsTab">
<ListView ItemsSource="{Binding XPath=Stats}" Height="310" Name="EnemyStatViewDisplay" Width="411" HorizontalAlignment="Left">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Attribute.Name}" />
<TextBlock Text="{Binding Path=Attribute.Value}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</TabItem>
The TabControl.DataContext binding exposes the parent XMLNode of the Stats element. I know this for certain as I'm using subnodes of the parent elsewhere and they work correctly. I don't know what to put for the ListView ItemsSource or for the DataTemplate's textblock binds. Does someone know how to do this?