tags:

views:

32

answers:

2

Hi, i've DataGrid with CurrentItem bind on property. DataGrid has implemented Paging. If i select in first page items, CurrentItem is changing, all is right. But when i set another page...I change Observable collection to display another 30 rows, the CurrentItem binding doesn't be functional.

I have: <DataGrid CurrentItem="{Binding CurrentItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Orders}"> Thx for help :) dEVIANT

A: 

I'm not sure, I'm following your question - but, I'll take a wild guess :-). I'm guessing your problem is that the CurrentItem is no longer set (and no row is selected in the DataGrid) unless you manually select a new item in the DataGrid? If that is the case, you simply need to add a property in your DataGrid:

<DataGrid IsSynchronizedWithCurrentItem="True"/>

This will force the DataGrid to select the first item when data is reloaded.

Another wild guess:

When you set the new source - how do you do that? if you update your property with a new ObservableCollection without calling a PropertyChanged event your binding will no longer work (but then, your DataGrid shouldn't update either).

Hope, either of those help - otherwise, I need more info to help you :-).

Goblin
A: 

Hmm...it doesnt work.

Paging implemented from: http://www.eggheadcafe.com/tutorials/aspnet/8a2ea78b-f1e3-45b4-93ef-32b2d802ae17/wpf-datagrid-custom-pagin.aspx

You can download project...bind currentitem of datagrid with TwoWay mode to property on ViewModel, add a breakpoint and watch behavior.

On first page, all works, then you move to second...binding does not be functional.

dEVIANT
Have you tried adding a NotifyPropertyChanged("CurrentItem") in the RefreshProducts() call? Otherwise, could you show us what the CurrentItem property looks like in the ViewModel?
Goblin