Click_Event in the firsit level

11 posts, 0 answers
  1. runes
    runes avatar
    15 posts
    Member since:
    Mar 2009

    Posted 25 Mar 2009 Link to this post

    Hi,
    I have a context menu.
    the context menu has two levels : first level and from it exit second level.
    I want a click event on the first level .
    what I have now is when I click on the first level, the child(second level) opens,
    and then when I click on an item on the second level, the event that's assigned to
    the first level occurs.

    I want a click event on the first level .

    The code:

     

     

    <StackPanel x:Name="LayoutRoot" Background="White">

     

     

     

    <RadioButton Content="Click Me to Open the RadContextMenu">

     

     

     

    <telerikNavigation:RadContextMenu.ContextMenu >

     

     

     

    <telerikNavigation:RadContextMenu EventName="Click" x:Name="radContextMenu1" ShowDelay="1:0:0">

     

     

     

    <telerikNavigation:RadMenuItem Header="Item 1" x:Name="firstLevel">

     

     

     

    <telerikNavigation:RadMenuItem Header="Item 2" x:Name="secondLevel" />

     

     

     

    </telerikNavigation:RadMenuItem>

     

     

     

     

    </telerikNavigation:RadContextMenu>

     

     

     

    </telerikNavigation:RadContextMenu.ContextMenu>

     

     

     

    </RadioButton>

     

     

     

    </StackPanel>

     


    public

     

    partial class Page : UserControl

     

    {

     

    public Page()

     

    {

    InitializeComponent();

    firstLevel.Click +=

    new RoutedEventHandler(firstLevel_Click);

     

    }

     

     

    void firstLevel_Click(object sender, RoutedEventArgs e)

     

    {

     

    }

    }
    }

    Thanks,


  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 25 Mar 2009 Link to this post

    Hello runes,

    RadMenuItem that have subItems do not fire Click event - only MenuItems that don't have subItems fires it. You can use SubmenuOpened or SubmenuClosed event for menuItems that have subItems.

    Let me know if this works for you.

    Greetings,
    Hristo
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. runes
    runes avatar
    15 posts
    Member since:
    Mar 2009

    Posted 25 Mar 2009 Link to this post

    Thanks,
    I have a new question:
    How I remove from the context menu child when the child closed?
    I try to write in the function : 

    SubmenuClosed()

     

     

    for (int i = 0; i <count-1 ; i++)

     

    {

    firstLevel.Items.Remove(0);

    }

     

    and the items not removed.
    How I do it?????

  5. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 25 Mar 2009 Link to this post

    Hi runes,

    This way of removing items is correct.
    Just change count-1 to count in the for declaration because you have only 1 item and 0 < 1-1 is false (you won't enter in the for scope).

    Let us know if you need more help.

    All the best,
    Hristo
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. runes
    runes avatar
    15 posts
    Member since:
    Mar 2009

    Posted 25 Mar 2009 Link to this post

    I do it, but the items is not removed from the contect menu  :(  .
    I added the items in the function: 

     

    SubmenuOpened:

    void firstLevel_SubmenuOpened(object sender, RoutedEventArgs e)  
            {  
     
                RadMenuItem tt = new RadMenuItem();  
                tt.Header="eeeeeee";  
                firstLevel.Items.Add(tt);  
                count++;  
     
                RadMenuItem t3 = new RadMenuItem();  
                t3.Header = "wwwww";  
                firstLevel.Items.Add(t3);  
                count++;  
                  
            } 

    i removed the items in function:

     

    SubmenuClosed:

     

     

     void firstLevel_SubmenuClosed(object sender, RoutedEventArgs e)  
            {  
                for (int i = 0; i <count ; i++)  
                {  
                    firstLevel.Items.Remove(0);  
                }  
                  
            } 

    and the items adeed and removed at once.
    How I added items in open sub context menu and removed them in closed sub context menu??????
    thanks. 

  7. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 26 Mar 2009 Link to this post

    Hi runes,

    Can you elaborate more on your scenario? What you want to achieve?
    It is not a common scenario to add MenuItems in SubmenuOpened and remove them SubMenuClosed.

    Regards,
    Hristo
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  8. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 15 Jul 2010 Link to this post

    "RadMenuItem that have subItems do not fire Click event "
    This is kind of lame.  Seems like standard functionality to me.  The RadMenu for asp.net (web applications) supports this kind of behavior.  We can't use "submenu opened" because the submenu is opened on mouseover.  The user needs to be able to mouseover the menu item to see the submenu and then potentially click on the parent menu. 
  9. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 15 Jul 2010 Link to this post

    "RadMenuItem that have subItems do not fire Click event "
    This is kind of lame.  Seems like standard functionality to me.  The RadMenu for asp.net (web applications) supports this kind of behavior.  We can't use "submenu opened" because the submenu is opened on mouseover.  The user needs to be able to mouseover the menu item to see the submenu and then potentially click on the parent menu. 
  10. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 16 Jul 2010 Link to this post

    Hello Travis,

    The standard WPF menu does not raise Click event for items that have children. This was the case with RadMenu too, but probably an year ago we added the NotifyOnHeaderClick property to RadMenu that allows the cotnrol to raise events when you click on header items (items that have children).

    Sincerely yours,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 19 Jul 2010 Link to this post

    I was talking about web applications, not WPF.  The r.a.d.menu in web apps has a "NavigateUrl" property which works for top level menu items with children.
  12. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 19 Jul 2010 Link to this post

    Hi Travis,

    I am talking about RadMenu for Silverlight, which was designed to work exactly as the standard WPF Menu control.
     
    The WPF/Silverlight RadMenu does not have NavigateUrl property, it has Command/CommandParameter properties that allow you to execute any code, including navigation to other page. By setting NotifyOnHeaderClick the items that have children will execute their commands, as well as raise their Click events.

    Best wishes,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner