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

dropdown menu doesn't close after clicking

4 Answers 670 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 21 Jul 2014, 03:11 PM
Hi I am using RadMenu. I want the dropdown menu to close after one of the menuitems clicked.
I am using the attached code but it doesn't close at this point. I need to click outside of the menu to close that dropdown options. Please help.
<Button Style="{StaticResource AddButton}">
    <telerik:RadContextMenu.ContextMenu >
        <telerik:RadContextMenu EventName="Click" ItemsSource="{Binding NewEntityMenuItems}" StaysOpen="False">
            <telerik:RadContextMenu.ItemTemplate>
                <DataTemplate>
                    <telerik:RadMenuItem Header="{Binding Text}" Command="{Binding MenuItemClickedCommand}" StaysOpenOnClick="False"></telerik:RadMenuItem>
                </DataTemplate>
            </telerik:RadContextMenu.ItemTemplate>
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
</Button>

4 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 23 Jul 2014, 09:05 AM
Hi Andy,

The issue here is because of the used ItemTemplate. For this scenario you would need to use ItemContainerStyle with the desired properties set. Please check the following code snippet:

<Button Content="Button">
    <telerik:RadContextMenu.ContextMenu >
        <telerik:RadContextMenu EventName="Click" ItemsSource="{Binding NewEntityMenuItems}" StaysOpen="False">
            <telerik:RadContextMenu.ItemContainerStyle>
                <Style TargetType="telerik:RadMenuItem">
                    <Setter Property="Header" Value="{Binding Text}" />
                    <Setter Property="Command" Value="{Binding MenuItemClickedCommand}" />
                    <Setter Property="StaysOpenOnClick" Value="False" />
                </Style>
            </telerik:RadContextMenu.ItemContainerStyle>
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
</Button>

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Andy
Top achievements
Rank 1
answered on 24 Jul 2014, 01:35 PM
Thanks. It worked great! I have attached the image of the menu in my application. There is a gray rectangular  area (highlighted in the image with red color) along with the menu. How do we get rid of that. Let only the MenuItem Texts show up. 
0
Kalin
Telerik team
answered on 25 Jul 2014, 08:15 AM
Hi Andy,

You would need to set the IconColumnWidth property of the ContextMenu to 0 in order to achieve the desired appearance.

Hope this will work for you.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Andy
Top achievements
Rank 1
answered on 25 Jul 2014, 03:08 PM
Thanks..It Worked great.
Tags
Menu
Asked by
Andy
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Andy
Top achievements
Rank 1
Share this question
or