I have a "hidden" column (made visible for debugging) called "Index" that I am sorting by... When I first load the grid, the grid is loaded in the correct way - but probably because my list of objects is already sorted. I implemented some custom commands attached to buttons inside the GridViewRow Template for moving objects UP or DOWN in the grid. When the Move Up or Move Down buttons are pressed, the items are removed from the list, inserted at the right location and the list's Index properties are corrected for the new order...
BUT The first time I press Move Up or Move Down, the index changes (I see the indexes in the data records change), but the grid doesn't refresh the items. The NEXT time I press either button, the grid resorts but not in a nice way... Items are always in the wrong order.
For example:
Start with these objects in the grid
1 - AAA
2 - BBB
3 - CCC
Move Down for object AAA: Remove object AAA, insert at new spot in list, reindex. Grid shows:
2- AAA
1 - BBB
3 - CCC
Move Down for object AAA: Remove object AAA, insert at new spot in list, reindex. Grid shows:
2 - CCC
1 - AAA
3 - BBB
I may have to put a small sample together but I'm hoping not. Here is how I have my grid defined:
I tried adding a SortDescription object to the SortDescriptions collection in the grid loaded event, but that did the same thing.
Thoughts?
Greg
BUT The first time I press Move Up or Move Down, the index changes (I see the indexes in the data records change), but the grid doesn't refresh the items. The NEXT time I press either button, the grid resorts but not in a nice way... Items are always in the wrong order.
For example:
Start with these objects in the grid
1 - AAA
2 - BBB
3 - CCC
Move Down for object AAA: Remove object AAA, insert at new spot in list, reindex. Grid shows:
2- AAA
1 - BBB
3 - CCC
Move Down for object AAA: Remove object AAA, insert at new spot in list, reindex. Grid shows:
2 - CCC
1 - AAA
3 - BBB
I may have to put a small sample together but I'm hoping not. Here is how I have my grid defined:
<telerik:RadGridView x:Name="SettingsGrid" ItemsSource="{Binding ElementName=UC, Path=CurrentTeamProjectList}" ScrollMode="RealTime" |
AutoGenerateColumns="False" ShowGroupPanel="False" IsFilteringAllowed="False" ColumnsWidthMode="Fill" ShowColumnHeaders="False" |
CanUserFreezeColumns="False" CanUserReorderColumns="False" CanUserSortColumns="False" VerticalGridlinesVisibility="Hidden" |
Margin="4,2,4,2" Loaded="SettingsGrid_Loaded"> |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn UniqueName="Index" IsReadOnly="True" DataType="{x:Type System:Int32}"/> |
<telerik:GridViewDataColumn UniqueName="Name" IsReadOnly="True" DataType="{x:Type System:String}"/> |
<telerik:GridViewDataColumn UniqueName="Boolean1" DataType="{x:Type System:Boolean}"/> |
<telerik:GridViewDataColumn UniqueName="Boolean2" DataType="{x:Type System:Boolean}"/> |
<telerik:GridViewDataColumn UniqueName="NumSeconds" DataType="{x:Type System:Int32}"/> |
</telerik:RadGridView.Columns> |
<telerik:RadGridView.SortDescriptions> |
<cm:SortDescription PropertyName="Index" Direction="Ascending" /> |
</telerik:RadGridView.SortDescriptions> |
</telerik:RadGridView> |
I tried adding a SortDescription object to the SortDescriptions collection in the grid loaded event, but that did the same thing.
Thoughts?
Greg