Reputation: 1
After i'm dragging columns in listView, when i'm looking in the Columns collection in the GridView of the listView, the order of the columns remains the same in spite the fact that I changed the order of the columns. How can I get the new order of the columns?
Upvotes: 0
Views: 696
Reputation: 2563
Assuming your ListView is called "listView" and the window is called "MainWindow", in your code behind you can do-
public MainWindow()
{
InitializeComponent();
DataContext = this;
GridView gridView = (GridView)listView.View;
gridView.Columns.CollectionChanged += new NotifyCollectionChangedEventHandler(Columns_CollectionChanged);
}
void Columns_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Move)
{
//sender contains the order of the columns
}
}
Sender in the Columns_CollectionChanged method contains the order of the columns
Upvotes: 3