Hi,
We've created a base class/control which implements RadGridView (i.e. BaseGridView : RadGridView) which features code-behind logic that is bound to the UI's RadGridView, which we'd like to use across our application to elimintate repeated code.
We were able to create a solution that worked, however, we were required to create the RadContextMenu and the items manually in the base controls' constructor, where we would prefer to declare the RadContextMenu and the items in the XAML of the base control, like so:
<telerik:RadGridView x:Class="MyModule.BaseGridView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
...
<telerik:RadContextMenu x:Name="GridContextMenu">
<telerik:RadContextMenu.Items>
<telerik:RadMenuItem Name="mnuFilterItem" Header="Filter Selected" Click="FilterMenuItem_OnClick"/>
</telerik:RadContextMenu.Items>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
...
</telerik:RadGridView>
Here is sample usage in a View which implements the base control:
...
<views:BaseGridView Grid.Row="1"
ItemsSource="{Binding Path=MyData}"
AutoGenerateColumns="False"
IsReadOnly="False"
RowIndicatorVisibility="Visible"
HorizontalAlignment="Stretch"
SelectionMode="Extended"
SelectionUnit="Mixed"
ClipboardPasteMode="AllSelectedCells">
...
The XAML implementation is triggering the FilterMenuItem_OnClick event from the View which inherits this base view/control, however, we are experiencing a XAML exception when viewing the XAML in the designer of the View which is implementing the base control:
Method not found: 'Void Telerik.Windows.Controls.RadMenuItem.add_Click(Telerik.Windows.RadRoutedEventHandler)'.
Kindly advise. We have also tried manually hooking up the filter's click event in code-behind in the inheriting View's constructor like so:
mnuFilterItem.Click += new RadRoutedEventHandler(FilterMenuItem_OnClick);
However, the XAML exception in the implementing View persists.
Kind regards