2

这是我的 wpf 文件。我希望GridView支持多项选择。

            <ListView Name="deviceListBox"
                  Width="630"
                  Height="282"
                  HorizontalAlignment="Center"
                  VerticalAlignment="Center"
                  ItemsSource="{Binding Items}"
                  SelectionChanged="deviceListBox_SelectionChanged"
                  SelectionMode="Single">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn>
                            <GridViewColumn.HeaderTemplate>
                                <DataTemplate>
                                    <Label Width="15"
                                           Height="25"
                                           Margin="10,0,0,0"
                                           HorizontalAlignment="center"
                                           VerticalAlignment="Center" />
                                </DataTemplate>
                            </GridViewColumn.HeaderTemplate>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <controls:PresenceIndicator Width="35"
                        Height="30"
                        Margin="7,0,0,0"
                        HorizontalAlignment="center"
                        VerticalAlignment="Center"
                        PhotoDisplayMode="Large"
                        SingleClickAction="ShowContactDetails"
                        Source="{Binding Path=SipURI}" />
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn>
                            <GridViewColumn.HeaderTemplate>
                                <DataTemplate>
                                    <Label Width="95"
                                           Height="25"
                                           Margin="10,0,0,0"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Center"
                                           Content="Username"
                                           Foreground="Black" />
                                </DataTemplate>
                            </GridViewColumn.HeaderTemplate>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Label Height="30"
                                               Margin="7,0,0,0"
                                               HorizontalAlignment="left"
                                               VerticalAlignment="Center"
                                               Content="{Binding Path=Username}"
                                               Foreground="Black" />
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn>
4

2 回答 2

1

将您的 SelectionMode 更改为MultipleExtended。请参阅此 MSDN 帖子

于 2012-08-13T03:16:11.587 回答
-1

设置DataGrid.SelectionMode

<DataGrid SelectionMode="Single" ...
于 2012-08-13T03:16:18.523 回答