After read this article, I am trying to adapt the instructions to my xamGrid in Silverlight.
I have no problems on Code Behind, and my model has the IsChecked boolean exposed properly.
But, retemplating my xamGrid (the igPrim:ExpansionIndicatorCellControl) I added a checkbox, which will allow the user to select multiple rows.
The stage of my retemplate reached this point:
And the CheckBox has this code:
<CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding Path=DataItem.IsChecked}" />
But checking the CheckBox do not affect the DataItem, and even the data coming from the model with Ischecked = true also do not have effect.
Does the DataItem is visible inside the ExpansionIndicatorCellControl context?
This checkbox could be placed in a CheckBox column, but I have another grid which will need a column of values before the expansion column. So I will run into this problem anyway
I will test your suggestion, thanks!
Hi,
So you're in a ControlTemplate of the ExpansionIndicator, which is in the ControlTemplate of the ExpansionIndicatorCellControl.
So the Binding is not going to work
You should put the checkbox directly into the ExpansionIndicatorCellControl's Template.
Out of curiosity, why don't you just use a CheckBoxColumn? You can event mark it as Fixed.
-SteveZ
Yes, I know that article is focused on WPF, but it was helpful to know the path.
I changed the Binding to relative source, but unfortunately without success.
The CheckBox is inside the <ControlTemplate>, so this should not be the problem. I attached the XAML fragment with the complete template of this particular cell, maybe it helps.
Just to be sure, I set my grid to auto generate columns and the IsChecked column appeared and displaying the right information.
So I'm not sure where the problem is beginning.
That article was actually for the WPF XamDataGrid, not the silverlight XamGrid.
Anyways, you should be able to use a RelativeSource binding, and access the Cell.Row.Data property, assuming you're in the ControlTemplate of the ExpansionIndicatorCellControl.
IsChecked={Binding RelativeSource={RelativeSource TemplatedParent}, Path=Cell.Row.Data.IsChecked}}
Hope this helps,