gpt4 book ai didi

wpf - 如何在 wpf 中创建停靠( float )工具栏

转载 作者:行者123 更新时间:2023-12-04 18:19:34 25 4
gpt4 key购买 nike

我是 wpf 的新手。我必须像 ms - office 2003 工具栏一样在 wpf 中创建一个 float 的 ToolBar。这样我就可以将它放在上下左右的任何位置,就像在 Office 2003 中一样。

请帮帮我......................................

最佳答案

对于普通对接,您可以使用 DockPanel :

<DockPanel>
<Button DockPanel.Dock="Top">This would be a toolbar at the top</Button>
<Butto>This would the main work area</Button>
</DockPanel>

<DockPanel>
<Button DockPanel.Dock="Left">This would be a toolbar at the left</Button>
<Button>This would the main work area</Button>
</DockPanel>

您当然会使用更适合您需要的类而不是 Button。

然而,当您需要一个带有 float 窗口的窗口系统时,您将不得不恢复到第 3 方库,因为它 WPF 没有它,而且很难推出自己的。这里有一些库:

如果您真正需要的只是停靠 float 工具栏(没有其他窗口),您可以使用 ToolBar class结合ToolBarTray class .但是您需要编写代码来检测拖动,从可视化树中删除 ToolBar 元素,然后将其作为根可视化对象添加到您自己的 Window 或 HwndSource。然后,您需要检测窗口何时位于拖放区上方,以便将工具栏从窗口移至主窗口的可视化树并关闭另一个窗口。

关于wpf - 如何在 wpf 中创建停靠( float )工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2887386/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com