码迷,mamicode.com
首页 > Windows程序 > 详细

wpf TabControl控件的用法

时间:2015-07-01 15:38:05      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace wpf控件互相绑定
{
    /// <summary>
    /// Window2.xaml 的交互逻辑
    /// </summary>
    public partial class Window2 : Window
    {
        public Window2()
        {
            InitializeComponent();
        }
        //当点击打开的时候
        int i = 0;
        TabItem tab;
        TextBox tb;
        DataGrid dg;
      
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
           tab=new TabItem();  //造选项卡
           tab.Header = "新窗口" + (i+1);  //新选项卡的名字
           TabControl1.Items.Add(tab);  //选项卡集合

           TabControl1.SelectedIndex = i;

           tb = new TextBox();
           tb.Width = 200;
           tb.Height = 200;
        

           if (i==0)
           {
                 tab.Content = tb;
           }

           tab.MouseDoubleClick += tab_MouseDoubleClick;//双击关闭选项卡

           i++;  

        }

        private void tab_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            TabItem s = (TabItem)sender;
            TabControl1.Items.Remove(s);
        }

 

wpf TabControl控件的用法

标签:

原文地址:http://www.cnblogs.com/275147378abc/p/4613062.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!