WPF TabControl 与 WindowsFormsHost 未知边框问题
我正在 WPF 中编写一个文本编辑器,我似乎有一个无法删除的奇怪边框。
我有一个带有选项卡控件的网格,当用户选择“文件 -> 新建”时,我以编程方式向选项卡控件添加一个新的 tabitem。我将 tabitem 内容设置为 WindowsFormsHost 的实例,以便托管 ScintillaNet WinForms 控件。
问题是这样的: https://i.sstatic.net/kotSb.png
我非常确定边框不是来自 WinForms 控件本身,因为我在相同配置的其他地方使用过它,并且它没有边框。
您看到的红色边框是我添加的,以突出显示问题(在响应“文件”->“新建”的方法中),并使用以下代码:
tabControl.BorderThickness = new Thickness(3, 3, 3, 3);
tabControl.BorderBrush = Brushes.Red;
tabControl.Items.Add(tab);
tab.Focus();
您知道这个内部灰色边框来自哪里吗?
I am writing a text editor in WPF and I seem to have a strange border that I can't remove.
I've got a grid with a tabcontrol, and when a user selects "File -> New", I programatically add a new tabitem to the tabcontrol. I'm setting the tabitem content to an instance of WindowsFormsHost in order to host the ScintillaNet WinForms control.
Here's the problem: https://i.sstatic.net/kotSb.png
I'm pretty sure the border is not coming from the WinForms control itself, as I've used it elsewhere in the same configuration and it has no border.
The red border you see is added by me to highlight the problem (in the method that is responding to File -> New), with the following code:
tabControl.BorderThickness = new Thickness(3, 3, 3, 3);
tabControl.BorderBrush = Brushes.Red;
tabControl.Items.Add(tab);
tab.Focus();
Any ideas where this inner grey border is coming from?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 TabControl 上的 Padding,它是应用于托管子元素的边距。请参阅对齐、边距和填充概述。在默认 TabControl 样式中它设置为 4。尝试将 Padding 显式设置为零:
That is the Padding on the TabControl, which is a margin it applies to the hosted child element. See Alignment, Margins, and Padding Overview. It is set to 4 in the default TabControl style. Try setting the Padding to zero explicitly: