1
我正在嘗試將WPF用戶控件添加到現有的WinForms項目中,並使WPF UserControl停靠並填充整個空間。與ElementHost對接
有一個當前的框架將WinForms UserControls加載到父窗體(進入面板)以響應按鈕單擊。這是我試圖掛鉤 - 當前正在加載的WinForms UserControl將具有ElementHost。
層次:
- Form1.cs中 - 包含一個面板,其獲取動態加載
- 的WinForms用戶控件的WinForms用戶控件 - 包含ElementHost的
- WPF用戶控件
ElementHost將Dock設置爲Fill及其兒童屬性設置爲ucReport,這是一個WPF用戶控件,它具有以下的標記(只包括頂層設計):
<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>
的用戶控件的內容不垂直擴展當我調整的形式,但水平時,內容只能擴展到足以容納其內容。
當我在設計器中查看WinForms UserControl(具有ElementHost的)時,問題很明顯。指定的WPF內容正在渲染,並且從頂部到底部填充,但不是從左到右。
我很想知道,它是在XAML中必須設置(可能在UserControl聲明?)來獲得它來填充它的父容器,這是ElementHost - 我找不到屬性。
有人能給我啓發嗎?
看在老天的份上。當然。謝謝。 – 2009-06-11 15:57:01