Hi,
I'm trying to to accomplish the following: whenever a user right clicks whatever data grid, the same context menu should appear. One of the options in the context menu is the export to Excel. I'm trying to achieve this by creating a style for the RadGridView. Here's my xaml:
<
Style
x:Key
=
"TelerikGridViewContextMenuStyle"
TargetType
=
"{x:Type telerik:RadGridView}"
>
<
Setter
Property
=
"ContextMenu"
>
<
Setter.Value
>
<
ContextMenu
>
<
MenuItem
Header
=
"{bx:LocalizeBinding ExportToExcel, Global=True}"
Command
=
"{Binding ExportToExcelCmd}"
CommandParameter
=
"{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadGridView}}}"
>
<
MenuItem.Icon
>
<
Image
Source
=
"/Resources/Icons/Excel.png"
/>
</
MenuItem.Icon
>
</
MenuItem
>
</
ContextMenu
>
</
Setter.Value
>
</
Setter
>
</
Style
>
As you can see, I'm trying to pass the RadGridView as a parameter to the command. However, in my code, this parameter is always null. How come ?