This is a migrated thread and some comments may be shown as answers.

Button Column with command binding

1 Answer 490 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 18 Jun 2009, 02:43 AM
                    <telerik:GridViewDataColumn Width="25">  
                        <telerik:GridViewDataColumn.CellStyle> 
                            <Style TargetType="telerik:GridViewCell">  
                                <Setter Property="Template">  
                                    <Setter.Value> 
                                        <ControlTemplate TargetType="telerik:GridViewCell">  
                                            <Button   
                                            Command="{Binding IngredientDeleteCommand}" 
                                            HorizontalAlignment="Center"   
                                            VerticalAlignment="Center">  
                                                <Image Height="20" Width="20" Source="/CakeBoss.WPF;component/Images/delete.png" /> 
                                            </Button> 
                                        </ControlTemplate> 
                                    </Setter.Value> 
                                </Setter> 
                            </Style> 
                        </telerik:GridViewDataColumn.CellStyle> 
                    </telerik:GridViewDataColumn> 

I've got a column that is for deleting a row, and I'm using MVVM so i'm binding to a command instead of using the click event on the button.  The command does not fire from inside the grid, but the Click event does.   If I copy the button outside the grid the button works just great.  Any clues?

1 Answer, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 18 Jun 2009, 03:13 AM

Found a solution on Stack Overflow:

Command="{Binding DataContext.IngredientDeleteCommand, ElementName=ingredients}" 

Where the x:Name of the datagrid is ingredients

Tags
GridView
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Share this question
or