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

RadSplit button With DropDown Content as RadContextMenu with subitems

11 Answers 381 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Rakesh
Top achievements
Rank 1
Rakesh asked on 13 May 2013, 10:05 PM
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




11 Answers, 1 is accepted

Sort by
0
Rakesh
Top achievements
Rank 1
answered on 13 May 2013, 10:23 PM
I even tried to use Rad Menu instead of context menu. It did not help. Any suggestions or help is highly appreciated.
0
Stefan
Telerik team
answered on 16 May 2013, 10:48 AM
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.

0
Rakesh
Top achievements
Rank 1
answered on 16 May 2013, 10:49 PM
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
0
Stefan
Telerik team
answered on 17 May 2013, 11:14 AM
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.

0
Rakesh
Top achievements
Rank 1
answered on 17 May 2013, 05:16 PM
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 .
0
Stefan
Telerik team
answered on 22 May 2013, 11:55 AM
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.

0
Rakesh
Top achievements
Rank 1
answered on 05 Jun 2013, 06:06 PM
Hi Thanks for the reply. May I know in which version this issue will be fixed and when is the release date.

Thanks
Rakesh
0
Stefan
Telerik team
answered on 06 Jun 2013, 08:02 AM
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.

0
Travis
Top achievements
Rank 1
answered on 18 Jun 2013, 10:34 AM
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?
0
Stefan
Telerik team
answered on 19 Jun 2013, 01:24 PM
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.

0
Travis
Top achievements
Rank 1
answered on 19 Jun 2013, 10:06 PM
Roger that. Thank you...
Tags
Buttons
Asked by
Rakesh
Top achievements
Rank 1
Answers by
Rakesh
Top achievements
Rank 1
Stefan
Telerik team
Travis
Top achievements
Rank 1
Share this question
or