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

Button in RadGridView Column

2 Answers 237 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scuttle
Top achievements
Rank 1
Scuttle asked on 13 Jun 2017, 03:38 PM

Hi, 

I am trying to implement a button in RadGridView column but when clicking the cutton, nothing happens. Here is the actual code:

 

 <telerik:GridViewColumn                             
                            Width="Auto">
                            <telerik:GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <telerik:RadButton Content="Content" 
                                                       Command="{Binding myCommand}">                                                                                                                  
                                        <telerik:RadButton.Style>
                                            <Style TargetType="{x:Type telerik:RadButton}">
                                                <Style.Setters>
                                                    <Setter Property="Visibility" Value="Hidden"/>                                                    
                                                </Style.Setters>                                                
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Flag_ID}" Value="FlagStatus">
                                                        <Setter Property="Visibility" Value="Visible"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </telerik:RadButton.Style>
                                    </telerik:RadButton>
                                </DataTemplate>
                            </telerik:GridViewColumn.CellTemplate>
                        </telerik:GridViewColumn>

2 Answers, 1 is accepted

Sort by
0
Ning
Top achievements
Rank 1
answered on 14 Jun 2017, 12:23 AM

Dear Scuttle

I think maybe you can try to update the Command Binding from {Binding myCommand} to be {Binding DataContext.myCommand,RelativeSource={.....maybe the source is your RadGridView}}.

and the reason is that command binding's DataContext should be one model instance of RadGridView's ItemsSource, not expected ViewModel instance.

0
Scuttle
Top achievements
Rank 1
answered on 14 Jun 2017, 09:11 AM
Thanks you very much. This solves my problem. 
Tags
GridView
Asked by
Scuttle
Top achievements
Rank 1
Answers by
Ning
Top achievements
Rank 1
Scuttle
Top achievements
Rank 1
Share this question
or