I've just started to learn binding in WPF and am having some trouble with using multiple ObjectDataProviders with the same control.
I have two ObjectDataProviders :
- Is used to get a list of customer locations from a database and is used to populate a TreeView and
- Takes a location as a parameter and returns all the customers from that location, populating a listView.
I'd like to make it so that when I click on one of the TreeView items, that it would take the SelectedItem text as the parameter, use it to populate the listview.
<ObjectDataProvider
x:Key="getLocations"
ObjectType="{x:Type local:DataSetCreator}"
MethodName="getLocations"
/>
<ObjectDataProvider
x:Key="getCustomersFromLocation"
ObjectType="{x:Type local:DataSetCreator}"
MethodName="getCustomersFromLocation">
<ObjectDataProvider.MethodParameters>
<x:Static Member="System:String.Empty" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<TreeView HorizontalAlignment="Left"
Margin="12,12,0,12"
Name="treeView2" Width="186"
ItemsSource="{Binding Source={StaticResource getLocations}}" >
<TreeView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Country}" />
</DataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<ListView x:Name="lstCustomers"
ItemsSource="{Binding Source={StaticResource getCustomersFromLocation}}" Margin="204,41,12,12">
<ListView.View>
<GridView>
<GridViewColumn Header="CustomerID"
Width="200"
DisplayMemberBinding="{Binding Path=CustomerID}" />
<GridViewColumn Header="Company Name"
Width="370"
DisplayMemberBinding="{Binding Path=CompanyName}" />
</GridView>
</ListView.View>
</ListView>
Is it possible to achieve this within the XAML, or do I need to use the code-behind?