WPF 功能区 - 当高度小于 250 时自动折叠

发布于 2024-09-17 12:44:20 字数 136 浏览 5 评论 0原文

Salam,

任何人都可以帮助我使用 WPF 功能区吗?我注意到,当您给包含功能区控件高度小于 250 的窗口时,功能区会自动折叠。如果您明确将其可见性设置为“可见”,它会自动折叠后,仅显示标题栏而不显示选项卡。有什么办法可以阻止这种行为吗?

Salam,

Can any one help me please with the WPF Ribbon, I noticed that when you give the window that contains the ribbon control height less than 250 the ribbon auto collapse. after it auto collapses if you explicitly set it's visibility to Visible only the title bar is shown without the tabs. Any means to stop this behavior?

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

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

发布评论

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

评论(3

今天小雨转甜 2024-09-24 12:44:20

我找到了答案:

这是新发布的 Microsoft Ribbon 的内置行为:包含的窗口存储在 Ribbon 对象中,当窗口的宽度低于 300 或窗口的高度低于 250 时,Ribbon 会折叠,目的当然是在空间紧张的情况下,优先考虑文档,而不是Ribbon。在 Word 和 Excel 功能区中也存在相同的行为。

没有直接的方法可以覆盖此行为,但您可以执行以下操作:

1 - 从此页面下载并安装源和示例安装程序。

2 - 找到包含解决方案的 RAR 文件。

3 - 提取并打开解决方案。

4 - 找到 Ribbon 类(应该在 RibbonsControlsLibrary 项目中)

您可以从这里检查该类的实现,您可以看到该类的开头有两个常量导致了问题。您甚至可以考虑更改代码并重建整个项目(如果没有其他办法)。

public class Ribbon : Selector
{
      private const double CollapseWidth = 300.0; // The minimum allowed width before the Ribbon will be collapsed.
      private const double CollapseHeight = 250.0; // The minimum allowed height before the Ribbon will be collapsed.

      //....
}

原始解决方案帖子

I found the answer:

This is a built in behavior of the newly released Microsoft Ribbon: the containing window is stored in the Ribbon object and the Ribbon collapses When the width of the window is under 300, OR the height of the window is under 250, the purpose is of course is that when space is scarce, priority is given to the document, not the Ribbon. Same behavior is found in Word and Excel ribbons.

There is no streightforward way of overriding this behaviour but you can do the following:

1 - Download and install the Source and Sample installer from this page.

2 - Find the RAR file containing the solution.

3 - Extract and open the solution.

4 - Find the Ribbon class (should be in RibbonsControlsLibrary project)

You can examine the implementation of the class from here, you can see there are two constants in the beginning of the class that are causing the issue.. You might even consider changing the code and rebuilding the whole project if nothing else works.

public class Ribbon : Selector
{
      private const double CollapseWidth = 300.0; // The minimum allowed width before the Ribbon will be collapsed.
      private const double CollapseHeight = 250.0; // The minimum allowed height before the Ribbon will be collapsed.

      //....
}

Original solution post

帅冕 2024-09-24 12:44:20

我认为微软声称不允许您更改代码,而只能查看它以进行演示 - 所以更改和重建它可能不是一个好主意......

I think Microsoft claims that u are not allowed to change the code, but only to view it for e.g. presentations - so probably it would not be a good idea to change and rebuild it...

等待我真够勒 2024-09-24 12:44:20

为什么您需要这个,我认为您需要的东西不受支持,因为 Microsoft 不打算以 Office 2007 或 2010 上看到的方式以外的方式使用功能区控件。

为什么您需要它?

Why you need this, I think what you need is not supported because Microsoft did not intended for the Ribbon control te be used in a way other than what we can see on Office 2007 or 2010.

Why would you need that?

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