WPF 制表符边距
我有一个 WPF TabControl,带有一些 TabItem。我希望 TabItems 组的左侧和右侧有边距,如果这有意义的话。
我将在下面画一些 ASCII 艺术来说明这一点。我想要在选项卡一的左侧有固定的边距,但我也想要在选项卡三的右侧有固定的边距。
|--------------------------------------------------|
| |-----||-----||-----| |
| <-Margin-> | 1 || 2 || 3 | <-Margin-> |
|------------| ||-----||-----|-----------------|
| |
| How do I get margin or padding on both |
| sides of my tabs? |
| |
| |
|--------------------------------------------------|
选项卡的数量是无限的,因此随着添加更多选项卡,它们将堆叠起来。为此,它需要正确工作。
另外,请注意,我不想使整个选项卡控件变小。只是 tabitem 选项卡或标题或其他任何内容。
我发现如果我将选项卡设置为具有类似于“60,0,-60,0”的边距,我会在选项卡左侧获得所需的效果,但这似乎是一种黑客行为,并且不起作用对于右侧。
我在 VS 2010 中使用 WPF 4.0。
干杯!
I have a WPF TabControl, with some TabItems. I want margins on the left and right of the TabItems group, if that makes sense.
I'm going to draw some ASCII art below to make the point. I want a fixed margin to the left of tab one, but I also want a fixed margin to the right of tab three.
|--------------------------------------------------|
| |-----||-----||-----| |
| <-Margin-> | 1 || 2 || 3 | <-Margin-> |
|------------| ||-----||-----|-----------------|
| |
| How do I get margin or padding on both |
| sides of my tabs? |
| |
| |
|--------------------------------------------------|
The number of tabs is unlimited, so they will stack as more are added. It needs to work correctly for that.
Also, note, that I don't want to make the whole tab control smaller. Just the tabitem tabs or headers or whatever they are.
I found that if I set the tabs to have a margin of something like "60,0,-60,0", I get the desired effect to the left of the tabs, but that seems like a hack, and won't work for the right hand side.
I am using WPF 4.0 in VS 2010.
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用这种风格。
编辑
您可以直接将边距赋予 tabcontrol 的控件模板内的 tabpanel
检查链接了解更多
http://www.switchonthecode.com/tutorials/the-wpf-tab-control-inside-and-out
Try using this style.
EDIT
You can give the margin directly to the tabpanel inside the controltemplate of tabcontrol
Check the link for more
http://www.switchonthecode.com/tutorials/the-wpf-tab-control-inside-and-out