私は WPF でバインディングを学び始めたばかりで、同じコントロールで複数の ObjectDataProvider を使用する際に問題が発生しています。
私は2つの ObjectDataProviders を持っています:
- データベースから顧客の場所のリストを取得するために使用され、TreeView を設定するために使用されます。
- パラメータとして場所を取り、その場所のすべての顧客を返し、listView に入力します。
TreeView 項目の 1 つをクリックすると、SelectedItem テキストがパラメーターとして使用され、それを使用してリストビューに入力されるようにしたいと思います。
<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>
XAML 内でこれを達成することは可能ですか、それともコード ビハインドを使用する必要がありますか?