SplitButton stays open on click

2 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Feb 2012

    Posted 11 Feb 2012 Link to this post

    Hi - I have this split button with 3 menu items. When I click on one of the menu items, I'm expecting the dropdown to close. I tried creating a template which sets StaysOpenOnClick="False", also tried setting it to false directly on each menu item but the dropdown continues to stay open. I've also tried handling the Click event to close the button. Nothing seems to work. Any ideas?

    Here is the style I tried: 
    <Style TargetType="telerik:RadMenuItem">
        <Setter Property="Header" Value="{Binding RelativeSource={RelativeSource Self}, Path=Command.DisplayName, Mode=OneWay}" />
        <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=Command.Description, Mode=OneWay}" />
        <Setter Property="StaysOpenOnClick" Value="False" />

    Here is the click handler I tried:

            private void RadMenuItem_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
                RadMenuItem item = e.Source as RadMenuItem;

                RadDropDownButton btn = item.ParentOfType<RadDropDownButton>();

                if (btn != null)
                    btn.IsOpen = false;

    Here is the SplitButton:
    <telerik:RadSplitButton Command="{Binding Path=ThisButtonComman}"
                                        ToolTip="Default action."
                                        Content="Click this button"
                                        AutomationProperties.Name="Sweet split button.">
              <telerik:RadMenu telerik:StyleManager.Theme="Summer" Background="Transparent" Orientation="Vertical">
                <telerik:RadMenuItem Command="{Binding Path=Command1}"
                                           AutomationProperties.Name="Name1." />
                <telerik:RadMenuItem Command="{Binding Path=Command1}"
                                           AutomationProperties.Name="Name2." />
                <telerik:RadMenuItem Command="{Binding Path=Command3}"
                                           AutomationProperties.Name="Name3." />            

  2. Zarko
    Zarko avatar
    755 posts

    Posted 15 Feb 2012 Link to this post


     The style didn't work because the StaysOpenOnClick property is used when you have hierarchical RadMenu (with RadMenuItems inside other RadMenuItems). As for the event - the problem is that you search for parents of type RadDropDownButton, but you should search for RadSplitButton:

    RadMenuItem item = e.Source as RadMenuItem;
    RadSplitButton btn = item.ParentOfType<RadSplitButton>();
    if (btn != null)
        btn.IsOpen = false;
    If you need further assistance please feel free to ask.All the best,
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top