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

telerik:RadContextMenu.ContextMenu in ControlTemplate.Resources

1 Answer 166 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Amar Deep
Top achievements
Rank 1
Amar Deep asked on 07 Dec 2010, 11:04 AM
Is this possible to put  <telerik:RadContextMenu.ContextMenu>  in  <ControlTemplate.Resources> and trigger Opened event of the context menu, if yes then please send the code.

Thanks
Amar

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 09 Dec 2010, 09:40 AM
Hello Amar Deep,

In WPF it is possible to specify RadContextMenu is Resources and then attach it to some element.
This is possible only if you set x:Shared="False" on the RadContextMenu. This will cause new instance to be created every time you reference this resource (limitation of RadContextMenu is that it cannot be attached on multiple elements but x:Shared helps in this case).

Here is simple code:
<UserControl x:Class="Application1.MainPage"
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"
      
    <UserControl.Resources>
        <telerik:RadContextMenu x:Shared="False" x:Key="contextMenu">
            <telerik:RadMenuItem Header="Item 1" />
            <telerik:RadMenuItem Header="Item 2" />
        </telerik:RadContextMenu>
    </UserControl.Resources>
      
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadGridView x:Name="radGrid" Width="1000" Height="750"
telerik:RadContextMenu.ContextMenu="{StaticResource contextMenu}"/>
    </Grid>
  
</UserControl>

Let us know if you need more details.

Regards,
Hristo
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
ContextMenu
Asked by
Amar Deep
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or