RadSplit button With DropDown Content as RadContextMenu with subitems

12 posts, 0 answers
  1. Rakesh
    Rakesh avatar
    23 posts
    Member since:
    May 2013

    Posted 13 May 2013 Link to this post

    Hi
    I am using a Radsplitbutton and its dropdown contents is a RadCOntextMenu which has subitems. The issue is when I expand the dropdown and mouse over on the item with subitems the submenu item is popped up and now I click outside the control .I see the popped up submenu item is closed but I want the dropdown also to be closed. Any help is much appreciated. Here is the sample code.
    My XAML:

     

     

     

    <Style x:Key="Group" TargetType="telerik:RadSplitButton">
    <Setter Property="controls:ImageContentSetter.Source" Value="/Images/group.ico"/>
    <Setter Property="ToolTip" Value="{x:Static Properties:Resources.Group_ToolTip}"/>
    <Setter Property="IsToggle" Value="True"/>
    <Setter Property="cal:Message.Attach" Value="[Event Click] = [Action ToggleGroupBy()]"/>
    <Setter Property="IsChecked" Value="{Binding DocumentGroupingIsSet, Mode=TwoWay, UpdateSourceTrigger=Explicit}"/> <!-- TwoWay/Explicit allows the binding to work as a Get and not Set-->
    <Setter Property="DropDownContent" Value="{Binding}"/>
    <Setter Property="DropDownContentTemplate">
    <Setter.Value>
    <DataTemplate>
    <telerik:RadContextMenu>
    <i:Interaction.Behaviors> <uiExt:CloseDropDownBehavior/> 

    </i:Interaction.Behaviors>  

    <telerik:RadMenuItem Header="{x:Static Properties:Resources.Group_Header}" cal:Message.Attach="ToggleGroupBySetting('Cluster')" IsCheckable="True" StaysOpenOnClick="False" IsChecked="{Binding DocumentGrouping, Converter={StaticResource GroupedMenuItemsConverter}, ConverterParameter=Cluster, Mode=TwoWay}" >

     

    <telerik:RadMenuItem.Icon>

     

    <Image Height="24" Width="16" Source="..\..\Images\cluster.png" />
    </telerik:RadMenuItem.Icon>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="{x:Static Properties:Resources.GroupByDocumentFamily_Header}" > <telerik:RadMenuItem.Icon>
    <Image Height="24" Width="16" Source="..\..\Images\sort_by_family.png" />
    </telerik:RadMenuItem.Icon>
    <telerik:RadMenuItem Header="{x:Static Properties:Resources.StandardListSort_Header}" cal:Message.Attach="ToggleGroupBySetting('DocFamilyListOnly')" IsCheckable="True" StaysOpenOnClick="False" IsChecked="{Binding DocumentGrouping, Converter={StaticResource GroupedMenuItemsConverter}, ConverterParameter=DocFamilyListOnly, Mode=TwoWay}" />
    <telerik:RadMenuItem Header="{x:Static Properties:Resources.ParentOrChildPrimarySort_Header}" cal:Message.Attach="ToggleGroupBySetting('DocFamilySortParentChild')" IsCheckable="True" StaysOpenOnClick="False" IsChecked="{Binding DocumentGrouping, Converter={StaticResource GroupedMenuItemsConverter}, ConverterParameter=DocFamilySortParentChild, Mode=TwoWay}" />
    <telerik:RadMenuItem Header="{x:Static Properties:Resources.ParentPrimarySort_Header}" cal:Message.Attach="ToggleGroupBySetting('DocFamilySortParent')" IsCheckable="True" StaysOpenOnClick="False" IsChecked="{Binding DocumentGrouping, Converter={StaticResource GroupedMenuItemsConverter}, ConverterParameter=DocFamilySortParent, Mode=TwoWay}" />
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="{x:Static Properties:Resources.GroupbyEmailThread_Header}" cal:Message.Attach="ToggleGroupBySetting('EmailThreading')" IsCheckable="True" StaysOpenOnClick="False" IsChecked="{Binding DocumentGrouping, Converter={StaticResource GroupedMenuItemsConverter}, ConverterParameter=EmailThreading, Mode=TwoWay}" >
    <telerik:RadMenuItem.Icon>
    <Image Height="24" Width="16" Source="..\..\Images\email_threads.png" />
    </telerik:RadMenuItem.Icon>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="{x:Static Properties:Resources.GroupExactDuplicates_Header}" cal:Message.Attach="ToggleGroupBySetting('ExactDuplicates')" IsCheckable="True" StaysOpenOnClick="False" IsChecked="{Binding DocumentGrouping, Converter={StaticResource GroupedMenuItemsConverter}, ConverterParameter=ExactDuplicates, Mode=TwoWay}" >
    <telerik:RadMenuItem.Icon>
    <Image Height="24" Width="16" Source="..\..\Images\group_exact_duplicates.png" />
    </telerik:RadMenuItem.Icon>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="{x:Static Properties:Resources.GroupNearDuplicates_Header}" cal:Message.Attach="ToggleGroupBySetting('NearDuplicates')" IsCheckable="True" StaysOpenOnClick="False" IsChecked="{Binding DocumentGrouping, Converter={StaticResource GroupedMenuItemsConverter}, ConverterParameter=NearDuplicates, Mode=TwoWay}" >
    <telerik:RadMenuItem.Icon>
    <Image Height="24" Width="16" Source="..\..\Images\group_near_duplicates.png" />
    </telerik:RadMenuItem.Icon>
    </telerik:RadMenuItem>
    </telerik:RadContextMenu>
    </DataTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    <

     

     

    telerik:RadSplitButton x:Name="Group" Style="{StaticResource Group}" />

     



    code for menu item click event:

    private void MenuItemOnClick(object sender, RadRoutedEventArgs radRoutedEventArgs)

    {
    RadMenuItem menuItem = sender as RadMenuItem;
    if(menuItem == null)  

    Debug.Assert(false, @"Unexpected object type.");

    return

    if(menuItem.Items.Count > 0)

    {
    // normally, menu items with child menu items  

    // do not generate a 'Click' event however, 

     

    // if an item in its sub-menu has StaysOpenOnClick set
    // we get a 'Click' event from the parent menu item!
    return;

    }
    if(menuItem.StaysOpenOnClick)
    {
    // honor 'StaysOpenOnClick' behavior
    return;
    }
    RadDropDownButton dropDownButton = menuItem.ParentOfType<RadDropDownButton>();
    if (dropDownButton != null)
    {

    dropDownButton.IsOpen = false;
    }
    else
    {
    RadSplitButton splitButton = menuItem.ParentOfType<RadSplitButton>();
    if (splitButton != null)
    {

    splitButton.IsOpen = false;
    }
    else
    {
    Debug.Assert(false, @"Cannot find parent RadDropDownButton or RadSplitButton.");
    }

    }

    }

    I want the dropdown to be closed when clicked outside the control when the menu item with submenu is expanded.Please help me to resolve this issue

    Thanks
    Rakesh




  2. Rakesh
    Rakesh avatar
    23 posts
    Member since:
    May 2013

    Posted 13 May 2013 Link to this post

    I even tried to use Rad Menu instead of context menu. It did not help. Any suggestions or help is highly appreciated.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 16 May 2013 Link to this post

    Hi Rakesh,

    I can suggest you in order to close the RadSplitButton's dropdown content when the submenu item is closed to handle the RadMenuItem's SubmenuClosed event and to set RadSplitButton's IsOpen property to false in the event handler.

    Please examine the attached project and tell us if it works for you.

    Regards,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Rakesh
    Rakesh avatar
    23 posts
    Member since:
    May 2013

    Posted 16 May 2013 Link to this post

    Hi Stefan
    Thanks for the reply.
    The idea you suggested works but again its kindaa weird because when you click on the dropdown and hover over the menuitem which has submenus then the submenu items are popped out and now you move the mouse then the submenu is closed and this is resulting in closing of the dropdown(splitbutton). The idea you suggested works fine when you do a selection or if user does not select any subitems and clicks outside the control. The radsplit button should not be closed if the user hovers over the items.
    Any idea on this is highly appreciated.

    Thanks
    Rakesh
  6. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 17 May 2013 Link to this post

    Hi Rakesh,

    I noticed I have tested your scenario with only one MenuItem, that's why I have missed the case you described.

    I just had to develop further my idea - before to close the RadSplitButton's Dropdown content it should be checked if any other of the RadContextMenuItem is focused and there is no focused RadMenuItem then to close the dropdown content.

    I attached the edited project in order to check the implementation of my suggestion.

    All the best,
    Stefan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Rakesh
    Rakesh avatar
    23 posts
    Member since:
    May 2013

    Posted 17 May 2013 Link to this post

    Hi Stefan
    Thanks for your support. I see one more issue here. I added one more menu item to the drop down in the project you have sent  which doesn't have any sub items.
    Use Case 1(Failing)
    Click on the split button.Now focus on one menu item which has sub items. The sub menu will be popped up. Now focus to the item which doesn't  have any sub items. Now click somewhere in the app outside this control. The drop down is still visible.
    Use Case 2(Passed):
    Click on the split button. Now focus on the menu item which doesn't have sub items. Now click outside somewhere in the application. The drop down is not visible .This is working as expected.
    I read somewhere that the Rad Split button will close by itself if you click outside the scope of the control like the above scenario. Is that true?.If so is this a bug in Rad Split Button control.

    I tried to attach the sample but I am having issues in attaching. Please add one more menu item without subitems to the project you provided .
  8. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 22 May 2013 Link to this post

    Hi Rakesh,

    The RadSplitButton should be closed by itself when the user clicks outside it, but there is a known limitation when in the RadSplitButton's Dropdown content is used a RadMenu. This issue is solved in our upcoming release, which is going to be announced in about 2 weeks.

    As a temporary workaround I can suggest you to handle the MouseDown event of the main window and in the handler to check if the RadSplitButton's IsOpen property is "True".

    Regards,
    Stefan
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  9. Rakesh
    Rakesh avatar
    23 posts
    Member since:
    May 2013

    Posted 05 Jun 2013 Link to this post

    Hi Thanks for the reply. May I know in which version this issue will be fixed and when is the release date.

    Thanks
    Rakesh
  10. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 06 Jun 2013 Link to this post

    Hi Rakesh,

    The issue's fix is going to be released with the upcoming Q2 official release, which is scheduled for the end of the next week.

    Regards,
    Stefan
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  11. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 18 Jun 2013 Link to this post

    Ditto, not closing with the submenu, it's generally any opportunity for the menu to "lose focus". Click outside its region, or anything like that. Menu should close. It currently does not.

    Haven't upgraded yet. I believe I am still on 13'Q1 possibly. This is fixed in Q2 then?
  12. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 19 Jun 2013 Link to this post

    Hi Michael,

    This bug is fixed in our latest official release (2013.2.611). Please give it a try and let us know how it goes.

    Regards,
    Stefan
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  13. Travis
    Travis avatar
    49 posts
    Member since:
    Dec 2012

    Posted 19 Jun 2013 Link to this post

    Roger that. Thank you...
Back to Top
UI for WPF is Visual Studio 2017 Ready