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

using RadContextMenu for RadGridView

9 Answers 194 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Veena
Top achievements
Rank 1
Veena asked on 24 Jul 2019, 06:26 AM

I want to add context menu for RadGridView and tried below code.. but it gives error as in the attached screenshot. please let me know how to proceed.

 

<telerik:RadGridView x:Name="radGridView" AutoGenerateColumns="False">
            <ui:RadContextMenu.ContextMenu>
                <ui:RadContextMenu x:Name="GridContextMenu" />
            </ui:RadContextMenu.ContextMenu>
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding FirstName}" Header="First Name"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding LastName}" Header="Last Name"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Age}" Header="Age"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding IsMarried}" Header="Married"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

 

9 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 24 Jul 2019, 08:54 AM
Hello Praveena,

I've attached a small example based on your code, but I don't see an error. Can you please give it a try and let me know if I am missing something?

Additionally, you can check the Use RadContextMenu within RadGridView article.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Veena
Top achievements
Rank 1
answered on 24 Jul 2019, 09:04 AM
Hi I am still getting same issue. I assume RadContextMenu is part of Telerik.WinControls.UI and I installed Telerik wincontrols composite UI nuget package for this. it is not recognizing RadContextMenu.ContextItem and also tried setting it through c# code. it is not recognizing RadContextMenu.SetContextMenu also.
0
Veena
Top achievements
Rank 1
answered on 24 Jul 2019, 09:10 AM
If possible could you plz send your sample project will required dlls referenced / nuget packages installed.. I don't see any references in your project and it is giving error for Telerik controls. I don't have any installation for Telerik controls. I am supposed to use nuget packages.
0
Martin Ivanov
Telerik team
answered on 24 Jul 2019, 11:06 AM
Hello Praveena,

Note that this is the UI for WPF forum. Implementations of the RadContextMenu control can be found in both UI for WPF and UI for WinForms products. The one from your code snippet is the RadContextMenu for WPF that is located in the "Telerik.Windows.Controls.Navigation.dll". 

The "Telerik.WinControls.UI.dll" is part of the UI for WinForms product and the RadContextMenu for WinForms is located there.

The attached project references the WPF dlls that can be downloaded from your telerik.com account. Or alternatively, you can search in the telerik nuget server using the dll names.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Veena
Top achievements
Rank 1
answered on 24 Jul 2019, 11:18 AM

Hi, 

I am using WPF form and I need wpf context menu for radgridview. So as per your reply I need to refer Telerik.Windows.Controls.Navigation in my project. May I know exactly which nuget package I have to install for this? I tried searching with the name "Telerik.Windows.Controls.Navigation" in nuget but could not get it.

0
Veena
Top achievements
Rank 1
answered on 25 Jul 2019, 02:41 AM

I somehow got the navigation dlls related nuget package and installed it. Now I tried to add static a context menu with one menu item as "Copy". But this is not showing context menu on grid. Do I have to build it dynamically even if I know the menus? I want to build static menu context here. Please help.

  <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu x:Name="audithistoryontextmenu">
                    <telerik:RadMenuItem Header="Copy" />
</telerik:RadContextMenu>

0
Martin Ivanov
Telerik team
answered on 25 Jul 2019, 08:54 AM
Hello Veena,

I am glad to hear that you managed to find the Telerik dlls. As for the menu, you can define also a static one in XAML. The only issue I saw from your last code snippet is that the RadContextMenu.ContextMenu closing tag is missing. Here is the fixed version of the snippet.
<telerik:RadContextMenu.ContextMenu>
    <telerik:RadContextMenu x:Name="audithistoryontextmenu">
        <telerik:RadMenuItem Header="Copy" />
    </telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
I also updated my last project to show this approach. I hope it helps.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Veena
Top achievements
Rank 1
answered on 25 Jul 2019, 09:35 AM

Hi,

Closing tag issue was just copy paste error while writing bug. my original code has proper tags and it is still not working. I have downloaded your sample code and installed below nuget packages as I don't have Telerik installed in my system. I am still not getting context menu on right click of any grid item. plz help. am I missing any packages or installed wrong packages?

 

<packages>
  <package id="Telerik.Windows.Controls.for.Wpf" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Controls.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Controls.GridView.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Controls.Input.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Controls.Navigation.for.Wpf" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Data.for.Wpf" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Data.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
</packages>

0
Accepted
Martin Ivanov
Telerik team
answered on 25 Jul 2019, 11:45 AM
Hi Veena,

As I can see some of the packages are Xaml and other NoXaml. You can read more about the differences between those types of dlls in the Xaml vs. NoXaml article.

The nuget packages without ".Xaml" contain NoXaml dlls. To show the missing context menu, you will need to download the .Xaml version of all dlls. Here is an example that shows the packages that should be updated:
<packages>
  <package id="Telerik.Windows.Controls.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Controls.GridView.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Controls.Input.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Controls.Navigation.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Data.for.Wpf" version="2019.2.618" targetFramework="net472" />
  <package id="Telerik.Windows.Data.for.Wpf.Xaml" version="2019.2.618" targetFramework="net472" />
</packages>
Here only the Navigation package should be Xaml. Note that I've also removed the first package because it was a duplicate of the second one from your last packages snippet.

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Veena
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Veena
Top achievements
Rank 1
Share this question
or