Hello,
I have a XamDataGrid which have a checkbox inside its ControlTemplate, On a button (outside the grid)click,how can I access the check box?
I assume you have made a style for the HeaderPrefixArea in which you put a checkbox. If so, just remove that style and the area will look regular, if not would you please provide me with some isolated sample so I can investigate it further for you.
Looking forward for your reply.
I was able to get individual checkboxes using
DataRecordPresenter recpresenter = DataRecordPresenter.FromRecord(AvailableBookGrid.ViewableRecords[0]) as DataRecordPresenter;
CheckBox cb = Utilities.GetDescendantFromName(recpresenter, "SelectionCheckbox") as CheckBox;
But how to remove parent checkbox?
Hello again,
If you don’t have ActiveRecord it is normal to get that exception. First you have to activate a record by clicking on it and then you can access its CheckBox using the code I posted previously.
Stefan,
Am getting Exception as "AvailableBookGrid.ActiveRecord" is null,I tried
DataRecordPresenter.FromRecord(AvailableBookGrid.FieldLayouts[0].DataPresenter.Records[0])
as DataRecordPresenter; too but its also throwing Error.
Do you have anyother approach for getting checkbox ?
TIA
Vivek
Hello Vivek,
Thank you for your post. I have been looking through it and I suggest you use the following code on order to access the ActiveRecord’s CheckBox:
DataRecordPresenter recpresenter = DataRecordPresenter.FromRecord(AvailableBookGrid.ActiveRecord) as DataRecordPresenter; CheckBox cb = Utilities.GetDescendantFromName(recpresenter, "SelectionCheckbox") as CheckBox;