1

这是我的 wpf 文件我想在单击列标题时对 GridView 进行排序我尝试这个 make<GridView AllowsColumnReorder="true">但不工作

对不起,我的英语不好

            <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

1 回答 1

1

我认为 ListView 默认不支持排序。你需要创建附加的依赖属性来处理排序。

参考 -单击列标题时自动对 GridView 进行排序

于 2012-08-13T05:52:04.597 回答