Hello,
I have been following this tutorial by Brian Lagunas, where he suggest how to create and data bind columns dynamically:
http://es.infragistics.com/community/blogs/blagunas/archive/2012/10/24/xamdatagrid-dynamically-create-and-data-bind-columns-with-an-editor-of-your-choice.aspx
I made everything work, it is displaying correctly on the screen, and also data is there. But when I edit the data in the XamDataGrid then nothing is happening in the ViewModel. The properties are not updated in the ViewModel.
My approach is a little bit different than the one Brian shows, but the bindings should work.
Can someone please tell me what I am doing wrong ?
For anybody else who might be interested in this matter:
I solved it by adding a command for the CheckBox in the CellValuePresenterStyle:
<Style x:Key="XamDataGridCellValuePresenterCheckBoxStyle" TargetType="{x:Type igDp:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDp:CellValuePresenter}"> <CheckBox IsChecked="{TemplateBinding Value}" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext.RoleGroupCheckBoxCommand}" CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </ControlTemplate> </Setter.Value> </Setter> </Style>
void RoleGroupCheckBoxCommand_OnClick(object obj) { var ob = obj as CellValuePresenter; if(ob == null) return; ob.Value = !((bool)ob.Value); }
Somehow the Grid var not updating the data in ViewModel.
Did anyone had time to check this matter ?