I'm really new in WPF and I need your help. I've app which allows user check continent and view containing countries. Country has two propetries: name and area. The problem is that I need to show average area of all continent's countries. My data model is looks like this:
<XmlDataProvider x:Key="CountryStoreDataSource" XPath="CountryStore">
<x:XData>
<CountryStore xmlns="">
<Continents Continent="Europe">
<Countries Country="Italy" Area="300"/>
<Countries Country="Iceland" Area="350"/>
</Continents>
<Continents Continent="Asia">
<Countries Country="China" Area="700"/>
<Countries Country="India" Area="650"/>
</Continents>
<Continents Continent="Africa">
<Countries Country="South Africa" Area="550"/>
<Countries Country="Egypt" Area="500"/>
</Continents>
</CountryStore>
</x:XData>
</XmlDataProvider>
also I have templates to connect listboxes with my data model:
<Grid.Resources>
<DataTemplate x:Key="countryItemTemplate">
<Label Content="{Binding XPath=@Country}"/>
</DataTemplate>
<DataTemplate x:Key="areaItemTemplate">
<Label Content="{Binding XPath=@Area}"/>
</DataTemplate>
</Grid.Resources>
finally I have the implementations of my listboxes:
<ListBox
Grid.Row="1"
ItemsSource="{Binding XPath=Countries}"
ItemTemplate="{StaticResource countryItemTemplate}"
Margin="0,0,0,0" />
<ListBox
Grid.Row="1"
ItemsSource="{Binding XPath=Countries}"
ItemTemplate="{StaticResource areaItemTemplate}"
Margin="0,0,0,0"
Grid.Column="1"
Name="listBoxAreas"
/>
Actually I don't know how to get my values from listboxes in c# code and is there any way to get values and do something with them in xml? Thank you.