c# - How to raise a click event when user clicks on a main menu sub item -


i have wpf app file menu bar following menu items:

  1. open
  2. recents
  3. save
  4. exit

the recents menu item gets populated recent open directories

recent: - ~\documents - ~\pictures

any pointers / suggestion, event should subscribe when user clicks on 1 of sub items within recents menu item?

many in advance!

the menuitem class has click event.

xaml:

<menu>     <menuitem header="file">         <menuitem header="open"/>         <menuitem x:name="recents" header="recents">             <menuitem header="documents" click="menuitem_click_1" />             <menuitem header="pictures" />         </menuitem>     </menuitem> </menu> 

code:

public mainwindow() {     initializecomponent();      menuitem mi = new menuitem() { header = "test" };     mi.click += menuitem_click_1;     recents.items.add(mi); }  private void menuitem_click_1(object sender, routedeventargs e) {     messagebox.show("clicked!"); } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -