Hi,
In our application, we sometimes have to clear out the Columns collection and then repopulate it from scratch based on some user settings. However, after calling Columns.Clear() and then repopulating the columns, the column headers don't reflect the correct sorting state, even though the data is still correctly sorted and the SortDescriptors collection has a sorting on the column.
For example, let's say in our MainPage's constructor I add a column bound to the ID property:
While the application is running, I click the column header to sort the data. (see columnsorting1.png)
In Button's click handler, I clear the Columns collection and then re-add a new column bound to ID:
When I click the button, the new ID column header shows no sorting state, even though there's a SortDescriptor that sorts on ID. (see columnsorting2.png)
I was able to reproduce the issue in the 2012.1 326 release.
In our application, we sometimes have to clear out the Columns collection and then repopulate it from scratch based on some user settings. However, after calling Columns.Clear() and then repopulating the columns, the column headers don't reflect the correct sorting state, even though the data is still correctly sorted and the SortDescriptors collection has a sorting on the column.
For example, let's say in our MainPage's constructor I add a column bound to the ID property:
public
MainPage()
{
InitializeComponent();
GridView.AutoGenerateColumns =
false
;
var column =
new
GridViewDataColumn()
{
DataMemberBinding =
new
Binding(
"ID"
),
};
GridView.Columns.Add(column);
Button.Click += Button_Click;
}
While the application is running, I click the column header to sort the data. (see columnsorting1.png)
In Button's click handler, I clear the Columns collection and then re-add a new column bound to ID:
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
GridView.Columns.Clear();
var column =
new
GridViewDataColumn()
{
DataMemberBinding =
new
Binding(
"ID"
),
};
GridView.Columns.Add(column);
}
When I click the button, the new ID column header shows no sorting state, even though there's a SortDescriptor that sorts on ID. (see columnsorting2.png)
I was able to reproduce the issue in the 2012.1 326 release.