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>
Hello,
Thank you for your post. I have been looking through it and I can say that if you didn’t set the XamDataGrid’s FieldSettings’ CellClickAction Property, its default value is EnterEditModeIfAllowed, which means that the Record is only selected if you click the RecordSelector at the beginning of the Row. If you then click at the Record itself, it becomes Unselected again. Please let me know if need further clarifications on this matter.
Looking forward for your reply.
Well, I added the following to my grid:
<igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings CellClickAction="SelectRecord"/> </igDP:XamDataGrid.FieldSettings>
I know this is not a problem with the code of the viewmodel, because I have successfully bound IsSelected in the same viewmodel with a ListBox and a ListView.
Attempting to attach the sample again in IE.
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.
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.
Thank you for your feedback. If you need further assistance on this matter feel free to write me.
Thanks again.
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?