与 TabItem 多次使用同一模块
这是我的场景:
- 具有 1 个 TabControl 和 1 个名为 MenuRegion 的区域的 Shell
- 包含每个可用模块(应用程序)的按钮。
我想使用 Prism(WPF 复合应用程序库)实现以下目标:单击其中一个按钮时,我需要向 TabControl 添加一个新的 TabItem,并在该 TabItem 内加载相应模块(应用程序)的单个实例。 一个模块可能会在 TabControl 中出现多次。
我真的很感谢你的回答。 但我不相信您正在使用 Prism (http://www.codeplex.com/CompositeWPF) 你是吗? 我的问题与 Prism 更相关,我现在对其进行了编辑以使其更加清晰。
在 Prism 中,您可以将模块的视图动态加载到区域中。 我不确定在我的场景中如何做到这一点,因为区域是动态设置的。 我该如何命名它们?
谢谢!
Here's my scenario:
- Shell with 1 TabControl and 1 region called MenuRegion
- MenuRegion contains Buttons for each of the available modules (applications).
I want to achieve the following using Prism (Composite Application Library for WPF): When one of the buttons is clicked, I need to add a new TabItem to the TabControl, and load and individual instance of the corresponding module (application) inside this TabItem.
One module may appear several times in the TabControl.
I really appreciate your answer. But I don't believe you're using Prism (http://www.codeplex.com/CompositeWPF) are you? My question was more related to Prism, and I've edited it to be more clear now.
In Prism you dynamically load modules' views into regions. I am not sure how to do that in my scenario because the regions are to be set dynamically. How would I name them?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我是这个 PRISM 世界的新手(1 周经验:)))并且有相同的要求!
首先,您必须从 此处。
我的(可能是你的)问题的解决方案如下:
有 2 个区域(菜单和 tabcontrol - 用于类似 mdi 的行为)
tabitem header 必须准备一个用于关闭的按钮(它绑定到一个用于关闭此 tabitem 的命令 - 实际上隐藏此 tabitem)
将事件从菜单项发送到应加载视图的模块(我已根据需要实例化了模块)。 在模块的初始化方法中订阅菜单项发送的事件。 在事件处理方法中,您只需重新显示 tabitem
如果这对您来说是抽象的,我可以向您发送一个我开发的框架应用程序来玩。
I'm new to this PRISM world (1 week experience :)) ) and had the same requirement!
First of all you have to get the Regionextensions from here.
The solution to my (may be your) problem is as follows:
have 2 regions (menu and tabcontrol - for mdi like behaviour)
tabitem header has to be prepared with a button for closing (which is bound to a command for closing this tabitem-actually hiding this tabitem)
send event from menu item to the module which should load the view (I've instantiated the modules on demand). In the module's initialize method subscribe to the event sent by the menu item. In the event handling method you simply re-show the tabitem
If this is to abstract to you I can send you a skeleton application I've developed to play around.
我们做了类似的事情,尽管我们已经创建了选项卡项目(没有内容)并根据需要显示/隐藏。 当选项卡项被选择时,我们加载选项卡内容。
选项卡项内容在选项卡项标记中指定,使用负责创建内容的页面。
该页面创建控件。
您可以使用类似的技术来动态创建选项卡项目。
We do something similar, though we have the tab items already created (with no content) and show/hide as appropriate. When the tab item is selected, then we load the tab content.
The tab item content is specified in the tab item tag, using pages which are responsible for creating the content.
The page creates the control.
You could use a similar technique to create your tab items on the fly.
我知道回复已经很晚了,但我正在做类似的事情,尽管尚未实现完整的解决方案。
此代码发生在我在演示器中处理的按钮的单击事件上。 该模块在配置文件中定义。
I know it's quite late a response but I am doing something similar, although haven't achieved the full solution yet.
This code happens on the click event of a button which I am handling in the presenter. The module is defined in the config file.