我有一个列表视图,其中包含一个带有网格列的网格视图,我想重新排序除第一列之外的所有列。我怎样才能做到这一点?我也想保存新的列位置。
我的列表视图代码是:
<Style x:Key="myListViewStyle" TargetType="{x:Type ListView}" x:Shared="False">
<Setter Property="BorderBrush" Value="RoyalBlue" />
<Setter Property="Foreground" Value="Teal" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="20, 60, 20, 50" />
<Setter Property="BorderThickness" Value="4, 4, 4, 4" />
<Setter Property="ListView.View">
<Setter.Value>
<GridView AllowsColumnReorder="True" >
<GridView.Columns>
<GridViewColumn Header="A/A" Width="30" DisplayMemberBinding="{Binding AA}"></GridViewColumn>
<GridViewColumn Header="Price" Width="350" DisplayMemberBinding="{Binding Price}" >
</GridViewColumn>
<GridViewColumn Header="Shop" Width="200" DisplayMemberBinding="{Binding Shop}" >
</GridViewColumn>
</GridView.Columns>
</GridView>
</Setter.Value>
</Setter>
</Style>
我也用这样的代码创建列表视图:
ListView l1 = new ListView();
l1.Style = Resources["myListViewStyle"] as Style;