以编程方式隐藏 WPF 功能区标题
我正在使用 VS2010 的 WPF Ribbon 应用程序。每个 RibbonGroup 都有一个 Header。即使我将标题留空,功能区仍然会为标题保留一个空白空间。如何以编程方式隐藏标题?
例如,我有以下 Xaml:
<ribbon:RibbonTab x:Name="HelpTab"
Header="Help" FontSize="10">
<ribbon:RibbonGroup x:Name="HelpGroup"
Header="Help Group" FontFamily="Verdana" FontWeight="Bold">
<!-- ..... -->
</ribbon:RibbonButton>
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
我想以编程方式隐藏由红色矩形标记的部分(标题文本和高度空间)。
我正在寻找一个 C# 代码背后的解决方案,我可以在其中隐藏文本和空间(高度)标头占据了所有内容,如下所示:
// of course, this doesn't work
HelpTab.HeaderStyle.Visibility = Visibility.Hide
I am using VS2010's WPF Ribbon Application. Each RibbonGroup has a Header. Even If I leave the Header empty, the Ribbon will still reserve an empty space for the Header. How can I programmatically hide the header?
For instance, I have following Xaml:
<ribbon:RibbonTab x:Name="HelpTab"
Header="Help" FontSize="10">
<ribbon:RibbonGroup x:Name="HelpGroup"
Header="Help Group" FontFamily="Verdana" FontWeight="Bold">
<!-- ..... -->
</ribbon:RibbonButton>
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
I want to programmatically hide the part (header text and height space) marked by red rectangle.
I'm looking for a C# code behind solution where I could hide the text and the space (height) the header takes up all together, something such as below:
// of course, this doesn't work
HelpTab.HeaderStyle.Visibility = Visibility.Hide
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过 VisualTreeHelper 来完成此操作。只需将行
MinHeight
设置为 0 :这是假设您没有设置
Header
属性。行高默认设置为自动
。因此,如果您设置Header
属性,您不妨将Height
设置为 0 :You can do it via the
VisualTreeHelper
. Just go set the rowMinHeight
to 0 :This is assuming that you didn't set the
Header
property. The height of the row is set by default toAuto
. So if you set theHeader
property, you might as well set theHeight
to 0 :您始终可以创建堆栈面板而不是功能区组。
You can always create stack panel instead of ribbon group.