Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPf ListView : Save reorderd column order

Tags:

For a WPF project in need to save the width and the column order of a ListView because these are things the user can change. I guess it is no problem getting the current width but the current position seems to be a bit difficult.

In WinForms there was something like index and displayIndex but I don't see it in WPF. How is it done?

BTW : Serializing the whole control is not an option.

Edit:

I found some samples using the listView.columns property. But I don't have such a property in my listView

My XAML code is like this:

<ListView>
    <ListView.View>
        <GridView>
            <GridViewColumn>
            ....
like image 661
TalkingCode Avatar asked Aug 07 '09 07:08

TalkingCode


1 Answers

I managed to do that using the Move(…) method of the GridView's Columns collection

If you have the new order stored somehow, you could try:

((GridView)myListView.View).Columns.Move(originalIndex, newIndex);

Edit: This is NOT XAML, but code you should put in the .xaml.cs file

like image 57
Teodor Avatar answered Oct 13 '22 10:10

Teodor