Hi,
i have an observable collection of say, 10 items, in my datagrid. Let's say i have the 5th item in the list clicked. I have a "previous record" button that when clicked, has a command that sets the previous (in our case, the 4th record) to activeRecord. however, when I click on a header and it resorts the columns, the observable collection is not updated. so when I click the button again, it gets the 3rd record from the observable collection and not my newly sorted list.
My DataPresenter's DataSource looks like this:
DataSource="{Binding Path=TenItemList, Mode=TwoWay}"
I have tried using the Sorted event and to sort with the CollectionViewSource however, that is not working either.
Is there an easy way to update the Observable Collection? or if not, is there a new list I should be getting the index from instead of the ObservableCollection?
I'm guessing there is a simple attribute that I need to set to get the observable collection synchronized with my new sorted list but i am a beginner, thanks!
Hello,
I am not sure I completely understood your requirement.
I am assuming that the button's command for activating previous record is DataPresenterCommands.RecordPrevious, is that right?
What this command does it to activate the record that is visible before the currently active one. So if you have records like:
OneTwoThree
and you select thee and then sort them ascendingly, you will get:
One> Three Two
When you hit the "previous" button, "One" would be selected. What is your expected result from this scenario?
I didn't know about that command! but yes, that is my expected result...
here is my scenario (very similar to the CustomerRelations in the infragistics showcase). I have a popup when a row is clicked, and i have a previous and next button on the popup that should change the active record to the one before or after, respectively.
I am using MVVM, and the datacontext of the popup is its respective row on the grid that it is related to.
when the button is clicked, if i want to use DataPresenterCommands.RecordPrevious, i would need the grid's datacontext.
right now i have a public property in the grid's viewmodel that sets the CurrentRecord and i have this in the grid's xaml:
<igDP:XamDataPresenter.ActiveRecord>
<MultiBinding Converter="{StaticResource dataItemToRecordConverter}" Mode="TwoWay">
<Binding ElementName="DataPresenter1" />
<Binding Path="CurrentRecord" Mode="TwoWay" />
</MultiBinding>
</igDP:XamDataPresenter.ActiveRecord>
is it possible to get the grid's view model to call the DataPresenterCommands.RecordPrevious?