setting IsOpen=true makes RadContextMenu staying opened

2 posts, 1 answers
  1. Daniel
    Daniel avatar
    23 posts
    Member since:
    May 2009

    Posted 24 Nov 2012 Link to this post

    <Rectangle Stroke="Black" StrokeThickness="1" Fill="#DADADA" Height="8" Width="8">
         <Rectangle.Triggers>
           <EventTrigger RoutedEvent="MouseLeftButtonDown">
             <BeginStoryboard>
               <Storyboard>
                 <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsOpen" Storyboard.Target="{x:Reference ContextMenu}">
                   <DiscreteObjectKeyFrame>
                     <DiscreteObjectKeyFrame.Value>
                       <sys:Boolean>True</sys:Boolean>
                     </DiscreteObjectKeyFrame.Value>
                   </DiscreteObjectKeyFrame>
                 </ObjectAnimationUsingKeyFrames>
               </Storyboard>
             </BeginStoryboard>
           </EventTrigger>
         </Rectangle.Triggers>
         <telerik:RadContextMenu.ContextMenu>
           <telerik:RadContextMenu x:Name="ContextMenu" ShowDelay="0">
             <telerik:RadMenuItem Header="Reset value" />
             <telerik:RadMenuItem Header="Set binding" />
           </telerik:RadContextMenu>
         </telerik:RadContextMenu.ContextMenu>
       </Rectangle>

    Click on the rectangle, then click somewhere else and radcontextmenu stays opened.  This way you can open multiple contexmenus simultaneously

    This does not happen with regular contextmenu.
  2. Answer
    Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 26 Nov 2012 Link to this post

    Hello Daniel,

    We'll check what is causing this behavior, but meanwhile I would suggest you to check this article which is describing how to open RadContextMenu on a specific event. In your case the code will look like this:
    <Rectangle Stroke="Black" StrokeThickness="1" Fill="#DADADA" Height="8" Width="8">
        <telerik:RadContextMenu.ContextMenu>
            <telerik:RadContextMenu x:Name="ContextMenu" EventName="MouseLeftButtonDown">
                <telerik:RadMenuItem Header="Reset value" />
                <telerik:RadMenuItem Header="Set binding" />
            </telerik:RadContextMenu>
        </telerik:RadContextMenu.ContextMenu>
    </Rectangle>

    If you use it this way, RadContextMenu will open only on MouseLeftButtonDown event and it will work as you expect.

    Hopefully this helps.

    Kind regards,
    Rosen Vladimirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top