Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
Commanding with XamDataGrid
posted

Hello,

I'm following an MVVM pattern, where I have a command in my view model called "GoCommand".  I'm displaying an ellipse in my XamDataGrid, and when the user clicks on the ellipse, my GoCommand is called.  I have all of this working fine, but I'm struggling with getting the current record passed to the view model.  In my view model command code, the parameter is always null, but I'm sure that's just because I can't get the XAML binding right.

I have this style in my XAML:

<Style x:Key="ellipseCVP" TargetType="{x:Type igDP:CellValuePresenter}">
    <Setter Property="ContentTemplate">
        <Setter.Value>
            <DataTemplate>
                <Ellipse x:Name="GoIcon" Width="12" Height="12">
                    <Ellipse.InputBindings>
                        <MouseBinding MouseAction="LeftClick" Command="{Binding Path=DataContext.GoCommand, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Record.DataItem}"/>
                    </Ellipse.InputBindings>
                </Ellipse>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>

I have this field in my XamDataGrid:

<igDP:Field Name="IsReady" Label="Ready?">
    <igDP:Field.Settings>
        <igDP:FieldSettings CellValuePresenterStyle="{StaticResource ellipseCVP}"/>
    </igDP:Field.Settings>
</igDP:Field>

As I said, everything works fine except that the CommandParameter is always null when it reaches my view model.  I've tried hard-coding a value just to make sure the "plumbing is correct" and that worked fine.  I know the problem is that I don't have the binding quite right on the CommandParameter of the MouseBinding.  Do you have any suggestions for the correct binding?

Thanks

Steve