我试图向现有的WinForms项目中添加一个WPF用户控件,并让WPF usercontrol停靠并填充整个空间。
当前有一个框架,用于响应按钮单击,将WinForms UserControls加载到父窗体(面板)中。这就是我想要连接的地方--目前正在加载的WinForms UserControl将有ElementHost。
等级:
包含获取动态loaded
的WinForms UserControls的面板的
ElementHost的Dock设置为Fill,其子属性设置为ucReport,这是一个WPF UserControl,它具有以下标记(仅包括顶层设计):
<UserControl x:Class="MyClassName"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TabControl HorizontalAlignment="Left" Name="tabControl1">
<TabItem Header="Header1">
...The interesting stuff goes here
</TabItem>
</TabControl>
</UserControl>当我调整表单的大小时,UserControl的内容确实会垂直展开,但在水平上,内容只会扩展到足以容纳其内容。
当我在设计器中查看WinForms UserControl (有ElementHost的那个)时,问题就很明显了。指定的WPF内容正在呈现,它是从上到下填充的,但不是从左到右。
我认为这是XAML中必须设置的东西(也许是在UserControl声明上?)要让它填充它的父容器,即ElementHost --我就是找不到这个属性。
有人能指点我吗?
发布于 2009-06-11 15:56:03
更改HorizontalAlignment以扩展或完全消除它。
https://stackoverflow.com/questions/981964
复制相似问题