复合 WPF 应用程序中的嵌套菜单区域

发布于 2024-07-30 05:45:23 字数 368 浏览 4 评论 0原文

复合 WPF 应用程序中是否可以有嵌套区域? 我希望模块能够注入新菜单,并且还能够将菜单项注入现有菜单。

使用以下代码,RegionManager 会引发异常:

区域管理器不包含MainFileMenuRegion区域

<Menu cal:RegionManager.RegionName="MainMenuRegion">
    <MenuItem cal:RegionManager.RegionName="MainFileMenuRegion" Header="_File" />
</Menu>

Is it possible to have nested regions in a Composite WPF application? I want modules to be able to inject new menus, and also be able to inject menu items into an existing menu.

Using the following code the RegionManager throws an exception:

The region manager does not contain the MainFileMenuRegion region

<Menu cal:RegionManager.RegionName="MainMenuRegion">
    <MenuItem cal:RegionManager.RegionName="MainFileMenuRegion" Header="_File" />
</Menu>

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

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

发布评论

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

评论(2

掩饰不了的爱 2024-08-06 05:45:23

我不知道它是否“正确”,但我通过在注入视图上有一个区域来进行嵌套,然后将子视图注入其中。

I don't know whether its 'right' but I do nesting by having a region on the injected view that I then inject the sub view into.

琴流音 2024-08-06 05:45:23

我想出的一种解决方法是简单地使用两个用 Grid 排列的 Menu。 第一个包含我所有的标准菜单,并允许我单独注入每个菜单。 第二个是空的,允许我注入新的顶级菜单。

One workaround I've come up with is to simply use two Menus arranged with a Grid. The first one has all my standard menus and allows me to inject into each one individually. The second is empty and allows me to inject new top-level menus.

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