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

RadContextMenu in a RadGridView

1 Answer 157 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
jholt asked on 02 Dec 2010, 11:06 PM
I have a RadGridView bound to a collection of ObservableCollection<Foo>. I am trying to bind a Command from the view model to a RadContextMenu, but it would seem that no matter how you describe the RelativeSource to the DataContext, the RadContextMenu is only taking its binding from the ItemsSource of the RadGridView. The routing worked perfectly well in the past using ContextMenu.MenuItem and using the hack of binding to the PlacementTarget.Tag, but no longer works when I changed from MenuItem to RadMenuItem (which are much nicer). I have had to resort to RadMenuItem_Click since I can find no way of getting the binding to work.

<Controls:RadGridView ShowGroupPanel="False"
                                  d:DataContext="{d:DesignData Source=../../DesignData/SampleBinderCollection.xaml}"
                                  SelectedItem="{Binding DataContext.SelectedBinder,Mode=TwoWay, RelativeSource={RelativeSource AncestorType=Window}}"
                                  Tag="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext}"
                        <Controls1:RadMenuItem Header="Go to this invoice/transaction"
                                  Command="{Binding DataContext.OpenTransactionWindowFromInvoiceCommand, RelativeSource={RelativeSource AncestorType=Window}}"
                                <Image Source="/Cornhouse;component/Images/NewCardHS.png"
                                       Height="16" />
etc ....
The viemodel is simply
public class MyViewModel:INotifyPropertyChanged
    public ICommand OpenTransactionWindowFromInvoiceCommand {get etc}
    public ObservableCollection<Foo> Collection
       get{return _collection;}

I would really appreciate some help with this.

Many thanks

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 08 Dec 2010, 08:23 AM
Hi Jeremy,

Please refer to the following help article:, it should help you resolve your issue.

Please let us know if that helped and if you have further questions.

Kind regards,
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question