ObservableCollection
次のようなものを含む辞書があります。
Dictionary<string, ObservableCollection<Person>> MyDictionary
今、私の xaml でitemscontrol
、辞書のキーをエキスパンダーに使用し、人のコレクションを次のlistview
ように使用する を作成しています。
<ItemsControl ItemsSource="{Binding MyDictionary}" VerticalAlignment="Center" HorizontalAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander Name="expander" IsExpanded="True">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="5" VerticalAlignment="Stretch" HorizontalAlignment="Left" Text="MyString:"/>
<TextBlock Margin="5" VerticalAlignment="Stretch" HorizontalAlignment="Left" Text="{Binding Key}"/>
</StackPanel>
</Expander.Header>
<Expander.Content>
<ListView SelectionMode="Single" ItemsSource="{Binding Value}">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn>
<GridViewColumn.Header>
<TextBlock Text="Name" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn>
<GridViewColumn.Header>
<TextBlock Text="Last Name" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding LastName}" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Expander.Content>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
ご覧のとおり、エキスパンダーのコレクションが作成され、各エキスパンダーにはそのコンテンツ内にリストビューがあります...
1 つのリストビューだけに項目を選択させたいのですが、どうすればよいですか?
明確でない場合: 3 がありExpanders
、それぞれに 1 がありListView
、それぞれListView
に 4 ~ 5 の項目があります。ユーザーがクリックすると、listviewitem
他のすべてのListViews
選択された項目が選択解除されるようにしたいと考えています。
ありがとう !