Wpf multiple listviews with shared selection (MVVM

2020-05-07 01:18发布

I have an issue with multiple listviews. I want them to have shared selection and SelectionMode=Extended

I managed to find a solution if SelectionMode=Single but it doesn't work for Extended situation

Basicly my code looks like this

    <ItemsControl ItemsSource="{Binding Items}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <ListView
                    SelectionMode="Extended" ItemsSource="{Binding items2}"
                    ItemTemplate="{StaticResource BubbleTemplate}"
                    SelectedValue="{Binding DataContext.SelectedValue,
                                RelativeSource={RelativeSource Mode=FindAncestor,
                                                               AncestorType={x:Type ItemsControl}}}" />
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl> 

It supports some kind of shared selection, so if i select item in one list view, items in other list view automatically deselect. But if i try to select multiple elements with Ctrl pressed it works only inside single list view.

Do you have any ideas how to solve this?

Thanks

0条回答
登录 后发表回答