WPF 工具栏有哪些优点?

发布于 2024-07-26 03:36:06 字数 317 浏览 1 评论 0原文

我正在尝试决定是否应该创建一个带有按钮的简单 StackPanel,或者是否应该使用 WPF ToolBar 类来包含这些按钮(我正在创建一个简单的工具栏)。

使用 WPF 的内置 ToolBar 控件有哪些优缺点?

到目前为止,这些是我看到的唯一优点:

  • 工具栏可以在必要时折叠; 其他项目可从上下文下拉列表中获得。
  • 如果 ToolBar 包含在 ToolBarTray 中,则多个 ToolBar 可以相对于彼此重新定位。

WPF 工具栏还有其他好处吗? 这些都不适用于我的简单工具栏。

I'm trying to decide whether I should create a simple StackPanel with Buttons on it, or whether I should use the WPF ToolBar class to contain these buttons (I am creating a simple toolbar).

What are the pros and cons to using WPF's built-in ToolBar control?

So far, these are the only advantages I have seen:

  • The ToolBars can collapse when necessary; additional items are available from a context drop down.
  • If the ToolBar is contained within a ToolBarTray, multiple ToolBars can be repositioned relative to each other.

Are the any other benefits to the WPF ToolBar? Neither of these apply to my simple toolbar.

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

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

发布评论

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

评论(3

硬不硬你别怂 2024-08-02 03:36:06

WPF 工具栏的辅助功能可能会更好,因为它向 Windows UI 自动化显示为带有工具栏按钮的工具栏,而不是一些随机控件。 您永远不知道谁会使用您的软件。

Accessibility might be better with the WPF Toolbar, because it shows itself to Windows UI Automation as a toolbar with toolbar buttons, rather than some random controls. You never know who'll use your software.

jJeQQOZ5 2024-08-02 03:36:06

另一个非常小的优点是,ToolBar 中的按钮将具有正确的样式,而 StackPanel 中的按钮将采用其默认外观。 无论如何,这并不是无法克服的,但还是有点烦恼。

Another very small advantage is that buttons in the ToolBar will be styled correctly, whereas the buttons in the StackPanel will take on their default look. Not insurmountable by any means, but a little annoyance none-the-less.

一口甜 2024-08-02 03:36:06

我会说使用工具栏,因为你永远不知道下一个项目何时出现并需要它。 你也永远不知道这个项目什么时候可能需要它。 我不认为在 StackPanel 上使用它有任何真正的缺点,而且您没有提到的优点是您将在下一个项目的内置控件方面拥有更多经验。

另一方面,我认为使用 StackPanel 进行此操作没有任何坏处,只是如果您将来需要扩展功能,则必须进行一些返工。

I would say use the Toolbar, because you never know when the next project will come along and need it. You also never know when this project may need it. I don't think there is any real drawback to using it over a StackPanel and the advantage you didn't mention is you'll have more experiance with a built in control for the next project.

On the other hand, I don't see any harm in doing it with the StackPanel, only that if you need to extend functionallity in the future, you'll have to do some rework.

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