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

[Solved] Button in Group Header Row

1 Answer 215 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Terry Foster
Top achievements
Rank 1
Terry Foster asked on 27 Jan 2011, 03:28 PM
Hi,

I see your demo where you can customize the content of a group header row by setting the GroupHeaderTemplate property, which is great.  However, I need to add a button as part of the content, but when I bind the Command property of the button to a property of my view model, nothing gets hooked up.  I'm assuming this is because my view model is not the data context for the group header row.  Can you provide an explanation of how I can handle a button click through command binding?

Thanks,
Terry

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 28 Jan 2011, 01:35 PM
Hello Terry Foster,

The DataContext of the GroupRow is the GroupViewModel. If you want a button defined in the GroupHeaderTemplate to invoke a command from your ViewModel, you may set this ViewModel in the Resource section and use it as a StaricResource afterwards:

<UserControl.Resources>
    <my:MyViewModel x:Key="MyViewModel"/>
</UserControl.Resources>
 
 
<telerik:RadGridView.GroupHeaderTemplate>
 <DataTemplate>
    <telerik:RadButton Content="click me" Command="{Binding MyCommand, Source={StaticResource MyViewModel}}" />
 </DataTemplate>
</telerik:RadGridView.GroupHeaderTemplate>


Kind regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Terry Foster
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or