WPF 面板标题标题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29356244/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF panel header title
提问by huber.duber
I am not sure they correct terminology for a header/title bar of a component in WPF. What I need is a panel/non-floating window, in which I can set the title? I want a few components in a panel that needs a title like Properties and Toolbox in Visual Studio.
我不确定他们是否正确使用 WPF 中组件的标题/标题栏的术语。我需要的是一个面板/非浮动窗口,我可以在其中设置标题?我想要一个面板中的一些组件,需要像 Visual Studio 中的“属性”和“工具箱”这样的标题。
As mentioned earlier, this doesn't need to be a floating/docking panel. I don't want GroupBox. I will be adding close button later just to hide the component from the user.
如前所述,这不需要是浮动/停靠面板。我不想要 GroupBox。稍后我将添加关闭按钮只是为了向用户隐藏组件。
回答by cypizek
I think, that in WPFvisual solutions are limited only by our imagination.
If isn't there control you want - you can build it.
我认为,在WPF视觉解决方案中仅受我们的想象力的限制。如果没有您想要的控制 - 您可以构建它。
My simple solution is here:
我的简单解决方案在这里:
<Border Visibility="Visible" BorderThickness="2" BorderBrush="Blue" CornerRadius="8" Margin="30,30,30,30">
<StackPanel Margin="3">
<Label Height="25" Content="H e a d e r" Background="LightSkyBlue" />
<Separator Height="5"/>
<Grid>
<!-- content -->
</Grid>
</StackPanel>
</Border>
Changing Visibility="Collapsed"you can hide this "panel".
改变Visibility="Collapsed"你可以隐藏这个“面板”。
回答by Karthik
If you don't need it to undock and float then you can use a HeaderedContentControl.
如果您不需要它来取消停靠和浮动,那么您可以使用HeaderedContentControl。
When you want to add the close button you can template the header presenter to include a button.
当您想要添加关闭按钮时,您可以将标题演示者模板化以包含一个按钮。

