telerik:RadContextMenu.ContextMenu in ControlTemplate.Resources

2 posts, 0 answers
  1. Amar Deep
    Amar Deep avatar
    3 posts
    Member since:
    May 2010

    Posted 07 Dec 2010 Link to this post

    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.

  2. Hristo
    Hristo avatar
    832 posts

    Posted 09 Dec 2010 Link to this post

    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"
            <telerik:RadContextMenu x:Shared="False" x:Key="contextMenu">
                <telerik:RadMenuItem Header="Item 1" />
                <telerik:RadMenuItem Header="Item 2" />
        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadGridView x:Name="radGrid" Width="1000" Height="750"
    telerik:RadContextMenu.ContextMenu="{StaticResource contextMenu}"/>

    Let us know if you need more details.

    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. DevCraft R3 2016 release webinar banner
Back to Top