在wpf中动态添加选项卡窗口 [英] Dynamically adding tab window in wpf

查看:347
本文介绍了在wpf中动态添加选项卡窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在用wpf制作应用程序,我需要的是wpf没有MDI格式,因此我决定在屏幕顶部制作一个菜单控件,并决定在侧面板中有一个子菜单.然后单击该子菜单,将在其余屏幕区域的选项卡控件中动态添加选项卡式窗口.

现在,单击顶部菜单控件,然后在stackpanel中动态添加子菜单usercontrol.

在包含子菜单事件的用户控件上,我要调用条目用户控制窗口并将其添加到主屏幕的选项卡控件窗口.我尝试实现ITabbed接口并实现该接口的添加选项卡"方法,但该选项卡未显示在主屏幕上....

请提出建议并帮我解决这个问题.....我真的被困住了..

谢谢&问候,
Krunal Panchal

Hello everyone,

I am making an application in wpf.what i need is as wpf doesn''t have MDI form i decided to make a menu control on top of the screen and decided to have a sub-menu in the side panel. and on click of that sub menus tabbed windows would be added dynamically in tab control in the remaining screen area.

Now on click of top menu control , i dynamically add sub-menus usercontrol in stackpanel.

On that user control which contains sub-menu events i want to call entry user-control window and add it to the tab control window of main screen. I tried implementing ITabbed Interface and implementing "Add Tab" method of that interface but the tab does not appears on the main screen ....

Please suggest and help me out on this.....i am really stuck up..

Thanks & Regards,
Krunal Panchal

推荐答案

检查一下:

在运行时在C#WPF应用程序中添加TabItem [ ^ ]

希望对您有所帮助:)
check this out:

Adding TabItem at runtime in a C# WPF application[^]

hope it helps :)


好,您可以将集合绑定到TabControl上的ItemsSource.如果要使所有选项卡仅基于同一模板,则只需创建一个包含所需表单的DataTemplate.在 Persist中,似乎有一篇文章可能对您有帮助在WPF TabControl中切换标签时的可视树 [
Ok, You can bind a collection to the ItemsSource on a TabControl. If you are going to have all tabs based only the same template, then you need to only create a DataTemplate that contains the form you need. There appears to be an article that might help you at Persist the Visual Tree when switching tabs in the WPF TabControl[^]

Hopefully that will help.


这里是MVVM使用TabControl的快速演示.

http://tap-source.com/mvvm-tabcontrol/ [
Here''s a quick demo of the MVVM way to use the TabControl.

http://tap-source.com/mvvm-tabcontrol/[^]

In this scenario, you would just add a new ItemViewModel to the Items collection when you select your menu item.


这篇关于在wpf中动态添加选项卡窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆