Hi,
I have an issue with the XamDataGrid and command parameter for my button on each row. By searching around for different solutions I found one that should work, but for some reason the DataItem of the CellValuePresenter is null. There are no errors in the Output-window, so the binding should work. I can verify that my command's CanExecute method is called, but the object parameter is null instead of the expected object.
My code for the unbound field in my grid is:
<igWPF:UnboundField Name="OpenButton" Label="" Width="1*"> <igWPF:UnboundField.Settings> <igWPF:FieldSettings> <igWPF:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igWPF:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <igWPF:ButtonTool x:Name="GridAddWallButton" Content="{x:Static r:SubProjectResources.WallGridFieldOpenButton}" Command="{Binding DataPresenter.DataContext.OpenWallCommand}" CommandParameter="{Binding DataItem}" HorizontalContentAlignment="Center"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </igWPF:FieldSettings.CellValuePresenterStyle> </igWPF:FieldSettings> </igWPF:UnboundField.Settings> </igWPF:UnboundField>
/ FW
<Button x:Name="myButton" Width="25" Command="{Binding Path=DataContext.Cmd, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" CommandParameter="{Binding DataItem}"/>