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
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
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
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.
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>
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
>
Regards,
Martin Ivanov
Progress Telerik
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>
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
>
Regards,
Martin Ivanov
Progress Telerik