DockPanel 和带有 Ribbon 控件的用户控制 UI
我有一个带有多个按钮的功能区控件,需要在窗口的主区域中显示不同的窗口/用户控件。我正在考虑为每个与其功能区中的按钮相关的“功能区域”创建一个用户控件。
像用户单击“首选项”按钮一样
Public Class RibbonViewModel
Public ReadOnly ucPreferences As UserControl = New ucPreferences
Public ReadOnly ucMain As UserControl = New ucMain
End Class
,我会这样做
dockMain.Children.Clear()
dockMain.Children.Add(oRibbon.ucPreferences)
,就布局而言,这是有效的,但我不确定可能会遇到什么问题。
I have a ribbon control with multiple buttons that need to display different windows/user control in the main area of the window. I'm thinking about creating a user control for each 'functional area' that relates to it's button in the ribbon.
Something like
Public Class RibbonViewModel
Public ReadOnly ucPreferences As UserControl = New ucPreferences
Public ReadOnly ucMain As UserControl = New ucMain
End Class
User clicks the Preference button and I'll do
dockMain.Children.Clear()
dockMain.Children.Add(oRibbon.ucPreferences)
This is working as far as the layout goes but I'm not sure what issues I might run into.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这肯定会起作用;然而,更强大的方法是使用 Prism...更具体地说是 IRegionManager< /a>.
这提供了一种在应用程序中定义区域的方法,您可以将内容推送到该区域内。一个例子是...
...其中
ad
是 AvalonDock 组装;但它也可能是您的DockPanel
。然后可以在后面的代码中引用它,如下所示......其中
_regionManager
是通过 DI 在对象构造函数中接收的实例,该对象将workspaceContent
放置在 <代码>工作区区域。这提供了与 Ribbon 操作的良好解耦,该操作将驱动为给定操作显示界面。它还提供了区域本身的抽象,即它是 DockPanel 还是其他控件。
如前所述,您的初始方法将会起作用。您是否应该选择像 Prism 这样的框架来隔离问题并增加功能取决于该项目现在和未来的规模。
This will certainly work; however a more robust approach would be making use of Prism...more specifically the IRegionManager.
What this provides is a way to define regions within your application where you can push content to live within the region. An example would be...
...where
ad
is the namespace for the AvalonDock assembly; however it could be yourDockPanel
just the same. This can then be referenced in the code behind as follows......where
_regionManager
is an instance received via DI within the contructor of the object placingworkspaceContent
in theWorkspaceRegion
.This provides nice decoupling with regard to the
Ribbon
action which will drive the interface to be displayed for that given action. It also provides an abstraction on the region itself, ie..is it aDockPanel
or some other control.As stated previously your initial approach will work. Whether you should opt for a framework such as Prism to isolate concerns as well as increased functionality is dependent on the scale of this project both now and in the future.