How to add WPF page to tabcontrol?

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

I have this main wpf window \"Main

and this WPF page

2条回答
  •  清歌不尽
    2021-01-12 12:05

    You can add user controls to the TabControl. So go to the add new items and select the user control and make what you want (like what you have in the page). Then add an instance of that user control to the TabControl.

    protected override void OnRender(DrawingContext drawingContext)
    {
        if (ISFirstRender)
        {
            TabItem tabitem = new TabItem();
            tabitem.Header = "Tab 3";
            pan1.Items.Add(tabitem);
    
            MyUserControl userControl = new MyUserControl();
            tabitem.Content = userControl;
    
            ISFirstRender = false;
        }
    
        base.OnRender(drawingContext);
    }
    

提交回复
热议问题