Wpf multiple listviews with shared selection (MVVM) [duplicate]

。_饼干妹妹 提交于 2020-02-16 10:40:34

问题


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

来源:https://stackoverflow.com/questions/59991712/wpf-multiple-listviews-with-shared-selection-mvvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!