具有上下文相关工具栏的 WPF 应用程序

发布于 2024-10-07 10:36:42 字数 252 浏览 0 评论 0原文

我想设计一个非常类似于 Visual studio 的应用程序,其中工具栏对工作区区域上下文敏感,并且它们是通用工具栏,具有上下文敏感功能,如剪切、复制、粘贴(对于这些我可以有应用程序命令)、选择注释(自定义命令)。

我想让工作区不知道工具栏控件。

我尝试使用自定义路由命令,但它仅适用于可视树中的父级(气泡路由策略),但我的工具栏和工作区位于 shell 中的同一级别。

他们是否有在 WPF 中设计此类应用程序的特定模式(我确信一定有)?

I want to design an application much like Visual studio where the toolbars are context sensitive to the workspace area and their are common toolbars which have context sensitive functionality like cut, copy, paste (for these I can have application commands), comment selected (custom commands).

I want to keep the workspace unaware of toolbar controls.

I tried using custom routed commands but it only works on parents in the visual tree (bubble routing strategy) however my toolbar and workspace are on the same level in the shell.

Are their specific patterns (I am sure there must be) for designing such an application in WPF?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然 2024-10-14 10:36:42

我实现了您所描述的一个简单版本,其中工具栏具有上下文相关的选项,并且只是显示或隐藏。该应用程序使用 MVVM 模式,因此我的工具栏有一个视图模型。我利用消息总线(有时称为事件聚合器)来发布工具栏的视图模型可以做出反应的消息。

I implemented a simple version of what you described, where a toolbar had options that were context sensitive and were simply shown or hidden. The application used the MVVM pattern, so my toolbar had a view model. I leverage the message bus (sometimes called event aggregator) to publish messages which the toolbar's view model could react to.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文