Hi
Is there anyway to provide the XamDataGrid with a custom Selection strategy? I would like the behaviour of the SelectionStrategyExtended, but as if the CTRL key was pressed all the time.
The reason that I need this is that I am trying to achieve a behaviour like the one Josh Smith does with the XamDataGridWithCheckedRecords sample (http://blogs.infragistics.com/blogs/joshs/archive/2008/09/04/adding-checkboxes-to-the-record-selectors-in-xamdatagrid.aspx) but without having to resort to individual view models. So far I have been successful using the Record.IsSelected bound to the check box - except for the fact that if you just miss the check box when you click, all selections are cleared and only that single selection remains.
Does anyone have any great ideas on how to do this - I guess there is a reason Josh choose the path that he did.
Regards Lau Bakman
Hello Lau,
I am guessing you want to select a Record only by clicking on it and deselect if it is already selected. It is easy to do that with
SelectionTypeRecord="Extended" and RecordActivated Event set IsSelected = True. Or am I missing something.
Alex.
Hi Alex
Hmm, no I think that would solve the oppsosite of my problem, I don't think I was clear enough - sorry.
I have a requirement that records should be selected by checking a CheckBox and only by checking a CheckBox. Josh Smith solves this by styling the record selector and binding to an IsChecked field in the view model of the data. I would like to avoid using a view model if I could and take advantage of the exiting selection functionality already present in XamDataGrid - by binding my CheckBox to IsSelected of the Record. I am setting the SelectionTypeRecord to Extended to allow multiple selection and I am telling the Cell's not to select on Click using CellClickAction != SelectRecord (Not like that of cause).
All this works like a charm and I select my records and the selection change event is fired and everything - my problem is that if I by accident miss the CheckBox and hit the RecordSelector area all my previous selections are cleared out and only the record in which I accidently clicked the RecordSelector area is now selected. This does not happen if I hold down CTRL - hence my idea about being able to override the strategy and fake the IsCTRLKeyPressed.
So in short my problem is not that my records are not selected - it is that my records are accidently deselected if I miss a CheckBox. Nevertheless your suggestion may still be appropriate - in reverse. I will try that.
[edit]No, that does not seem to be the case.
Regards Lau
Here is a solution that illustrates my problem. If someone thinks it looks remarkable like Josh's sample - they are absolutely right.
If you check the ceckboxes, the records are selected - but if you click rigt beside one the selections are reset and only the one record is selected.
I have found a solution that works for me. I am abusing the Tag property of the Recod to store my selected state - but it seems to do the trick. I have SelectAll, UnselectAll, ToggleItem and ToggleGroup functionality - although the toggle group is one way and not reflected back to the CkeckBox - can't figure that one out :-( The ToggleGroup will select all if no grouping is applied but only the individual group if grouping is applied
The Toggle Group is currently commented out in the XAML.
It may be possible to create a similar solution by using Attached Dependency Properties - like the Adorning Editors sample in the Feature Browser - but this one works nicely for me.
I have not tested how this works if Records are loaded on demand and I have only tested with a limited set of Records.
Regards
Lau Bakman