tags:

views:

472

answers:

1

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>
            ....
A: 

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);

Hope that helps,

Teodor

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

Teodor
This seems great to put the columns into a new order after I loaded it from disk. But how do get the current order from the ListView?
Holli
Well, i guess the current order is the default order of the columns, as designed. If this is correct, you should know which column is where.
Teodor