0
我在使用elementHost控件的WinForms中托管WPF控件。当我尝试调整元素主体大小(高度),然后再调整原始位置时,内部的子控件居中并在其周围出现黑色边框。当我试图修改孩子的尺寸以匹配宿主控制时,它仍然“居中”它,部分孩子被切断并且不适合。元素主机不能正确调整子项的大小
这里是我的大小调整的代码(这是在形式调整事件处理程序):
elementHost1.Height = ClientSize.Height - h;
elementHost1.Width = ClientSize.Width - w;
(elementHost1.Child as WPFCodeBox).textEditor.Height = ClientSize.Height - h;
(elementHost1.Child as WPFCodeBox).textEditor.Width = ClientSize.Width - w;
(elementHost1.Child as WPFCodeBox).Border.Width = ClientSize.Width - w;
(elementHost1.Child as WPFCodeBox).Border.Height = ClientSize.Height - h;
Where h is the distance from the bottom of the form to the bottom of the element host
same for w but in width.
感谢您的帮助!
嗨艾丹 - 如果你已经解决了你自己的问题,请张贴解决方案作为答案,并在时间过后,将其标记为已接受。这样,问题实际上会在整个网站上“回答”。 – 2012-03-14 21:55:01
将您的解决方案放入答案中并接受它。 – EricSchaefer 2012-03-14 21:56:04