请看下面的代码。当我单击 Revert to org order 按钮时,应将列重新排序为原始数据网格顺序。有没有可能?请帮帮我...... //以下是我的代码
<Window x:Class="GridTextBox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" WindowState="Maximized" Loaded="MainWindow_Loaded" Background="Gray">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".25*"/>
<ColumnDefinition Width=".25*"/>
<ColumnDefinition Width=".25*"/>
<ColumnDefinition Width=".25*"/>
</Grid.ColumnDefinitions>
<DataGrid ColumnReordered="datagrid1_ColumnReordered" GotFocus="datagrid1_GotFocus" LoadingRowDetails="datagrid1_LoadingRowDetails" Grid.ColumnSpan="3" Background="Gray" Grid.Row="1" Height="auto" Name="datagrid1" AutoGenerateColumns="False" Width="440" VerticalAlignment="Center" SelectionChanged="datagrid1_SelectionChanged">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Empid">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Name="txtEmpid" Text="{Binding Empid}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Empname">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Empname}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding Empname}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Empaddress">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Empaddress}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="EmpCity">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding EmpCity}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Empstate">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding EmpState}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="EmpCountry">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding EmpCountry}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<Button Grid.Row="2" Grid.Column="2" Height="30" Content="Insert Employees" Click="Button_Click"></Button>
<Button Grid.Row="2" Grid.Column="1" Height="30" Content="Revert to org order" Name="btn" Click="btn_Click"></Button>
</Grid>
</Window>