Double click event implementation on Silverlight 4 Datagrid

Does any good soul have an example of the "Command Pattern" implementation introduced by Prism in a double-click event in a Silverlight 4.0 DataGrid?

I tried the following:

<data:DataGrid x:Name="dgUserRoles" AutoGenerateColumns="False" Margin="0" Grid.Row="0" ItemsSource="{Binding Path=SelectedUser.UserRoles}" IsReadOnly="False">
    <data:DataGrid.Columns>
        <data:DataGridTemplateColumn Header="">
            <data:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <Button Width="20" Height="20" Click="Button_Click" Command="{Binding EditRoleClickedCommand}" CommandParameter="{Binding SelectedRole}" />
                </DataTemplate>
            </data:DataGridTemplateColumn.CellTemplate>
        </data:DataGridTemplateColumn>
        <data:DataGridTextColumn Header="Role Name" Binding="{Binding RoleName}" />
        <data:DataGridTextColumn Header="Role Code" Binding="{Binding UserroleCode}" IsReadOnly="True"/>
        <data:DataGridCheckBoxColumn Header="UDFM Managed" Binding="{Binding RoleIsManaged}" IsReadOnly="True" />
        <data:DataGridCheckBoxColumn Header="UDFM Role Assigned" Binding="{Binding UserroleIsUdfmRoleAssignment}" IsReadOnly="True" />
        <data:DataGridTextColumn Header="Source User" Binding="{Binding SourceUser}" IsReadOnly="True" />
    </data:DataGrid.Columns>
</data:DataGrid>

As you can see, I tried to connect the command there, and it does not fire an event in my view model.

Look for a good alternative.

+4
source share
1 answer

Firstly, Button.Command is not for double-clicking. It will work with one click.

You need to change that way. ElementName = dgUserRoles, Path = DataContext.

 Command="{Binding ElementName=dgUserRoles, Path=DataContext.EditRoleClickedCommand}"
0
source

All Articles