How to add WPF page to tabcontrol?

前端 未结 2 1183
天命终不由人
天命终不由人 2021-01-12 11:16

I have this main wpf window \"Main

and this WPF page

2条回答
  •  抹茶落季
    2021-01-12 12:12

    If you want to add a new Page, as opposed to a UserControl, you can create a new Frame object and place the page in there.

        if (ISFirstRender)
        {
            TabItem tabitem = new TabItem();
            tabitem.Header = "Tab 3";
            Frame tabFrame = new Frame();
            Page1 page1 = new Page1();
            tabFrame.Content = page1;
            tabitem.Content = tabFrame;
            pan1.Items.Add(tabitem);
    
            ISFirstRender = false;
        }
    

提交回复
热议问题