I'd like to bind xamDataGrid rows to an IsSelected property in my ViewModel, so I did this:
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<EventSetter Event="MouseLeftButtonUp" Handler="object_MouseLeftClick"/> <EventSetter Event="MouseDoubleClick" Handler="object_MouseDoubleClick"/> <EventSetter Event="MouseRightButtonUp" Handler="object_MouseRightClick"/> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
</Style>
I am concerned about the performance of your solution.
If I increase the number of items to 1000, the Select All command takes 2 full seconds :O
In my application there is a pair of lists, each will contain up to 1000 items, and I consider even a 1-second pause to be quite excessive on a 3 GHz machine. I notice it calls GetRecordFromDataItem(), whose documentation says "this may be an expensive operation depending on the size and structure of the data."
Can the selection be synchronized more quickly?
The code is a little odd too; why does it check IsMouseOver and what is the purpose of setting ActiveRecord = null?
Hello,
Thank you for your feedback. If you need further assistance on this matter feel free to write me.
Thanks again.
Well, your solution isn't immediately usable in my application because I rely on IsSelected flags in the viewmodel (I also use Update Controls, a framework that thrives on this approach). I have been busy with other things and will research ways to get this working when I have time.
First though, I will have to confirm that your solution actually does work -- since the other lists have been removed from the sample, it is not clear yet. But thanks for your assistance so far.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Hello again,
I have been looking through you sample and I can suggest you change the Binding in the DataRecordPresenter to DataItem.IsSelected, but since the XamDataGrid has a Record virtualization this will work only for the Records in view, because when they are scrolled out the DataRecordPresentrer is Disposed. One thing you can do is change the RecordContainerGenerationMode of the XamDataGrid, but this will slow down the performance. Other thing you can do is using the suggestion I implemented, in the sample I attached to this post, where I created a class that derives from the XDG and add a dependency property to it for the selected Records and used it for the Binding.
Hope this helps you.