简体   繁体   中英

Open content of Tabitem in new Window

What i want to do is open a new window exactly the same as my TabItem. I tried this:

Window wnd = new Window();
var cnt = tabItem1.Content;
wnd.Content = cnt;
wnd.Show();

After button click it open nice new window with tab control content, but content in my main window disappear. When I switch to another tab item in my main window and again to TabItem1 everything is ok in main window, but "new window" is empty then.

You can't use that code. Each WPF control can't have more than one parent in the logical (or visual) tree. Take a look here . You should use a template in order to have the same content both in your Tab Control and in your Window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM