wpf--menu bar and TabControl

Source: Internet
Author: User

First, create a form, and then add the menu bar and the original TabControl tab to the form

<Grid> <Menu> <menuitem header="file"click="Menuitem_click_3"> <menuitem header="Open a new window"click="Menuitem_click_1"></MenuItem> <menuitem header="Exit"click="Menuitem_click_4"></MenuItem> </MenuItem> <menuitem header="Help"> <menuitem header="About Us"></MenuItem> </MenuItem> </Menu> <tabcontrol name="TabControl1"Horizontalalignment=" Left"height="337"margin="0,20,0,0"Verticalalignment="Top"Width="572"> <tabitem header="Original Window"> <grid background="#FFE5E5E5"> <textbox horizontalalignment=" Left"height="305"margin="0"textwrapping="Wrap"text=""Verticalalignment="Top"Width="562"/> </Grid> </TabItem> &lt ;/tabcontrol> </Grid>

Second, when clicking Open a new window, the new window will pop up, and add a full text box in the new window (Adding a text box to the new tab has not been implemented)

  Public Partial classMainwindow:window { PublicMainWindow () {InitializeComponent (); }        Private inti =0;//define a I used to make the new item name differentTextBox T;//Create a new item and throw the textbox in .        Private voidMenuitem_click_1 (Objectsender, RoutedEventArgs e)//Open new Window button{TabItem ti=NewTabItem ();//Create a new tabTi. Header ="New Window"+ (i+1);//Name of new tabTabControl1.Items.Add (TI);//Throw the new tab into the TabControl1.t =NewTextBox ();//To manifest a new text boxT.width =562; T.height=305; //The following is the beginning of adding a text box to the newly created tab//each new window is highlighted by default as a new windowTabcontrol1.selectedindex = i+1; I++; }             Private voidMenuitem_click_4 (Objectsender, RoutedEventArgs e)//Close button        {             This.        Close (); }        Private voidMenuitem_click_3 (Objectsender, RoutedEventArgs e) {        }    }

wpf--menu bar and TabControl

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.