在同一个<dockpanel>中显示不同的“类型”

时间:2016-05-23 09:16:05

标签: c# wpf xaml user-interface

我的XAML中有以下结构:

<Window x:class=...>
    <Window.Resources>
        ...
    </Window.Resources>
    <Grid name="grid">
        <DockPanel>
            <!-- Some images displayed here -->
        </DockPanel>
        <DockPanel>
            <!-- Some more images displayed here -->
        </DockPanel>
        <TabControl ...>
            <TabItem ...>
                <DockPanel VerticalAlignment="Stretch" Height="Auto" HorizontalAlignment="Stretch" Width="Auto">
                    <Button Style=...>
                        <Image Sourcec=...>
                    </Button>
                    <Button Style=...>
                        </Image Source=...>
                    </Button>
                    <Grid x:Name="grdBrowserHost" Height="Auto" Width="Auto" Margin="0,30,0,0" VerticalAlignment="Top"></Grid>
                </DockPanel>
            </TabItem>
            ...
            </TabItem>
        </TabControl>
    </Grid>
</Window>

我在这个类的'代码隐藏'中也有以下C#:

public partial class MainWindow : Window{
    ...
    WebKit.WebKitBrowser browser = new WebKit.WebKitBrowser();
            System.Windows.Forms.Integration.WindowsFormsHost host = new System.Windows.Forms.Integration.WindowsFormsHost();

    ...

    public MainWindow(){
        ...
        try{
            browser.Navigate("www.google.com");
            host.Child = browser;

            grdBrowserHost.Children.Add(host);
            browser.Visible = true;
            browser.Navigate("https://www.google.com");
            browser.GetWebView();
            host.Opacity = 255;
            grdBrowserHost.Opacity = 200;
        }catch(Exception e){
            Console.WriteLine("exception caught");
        }
        ...
    }
}

但由于某种原因,当我运行应用程序时,虽然显示了GUI,所有TabItemButton显示并正常运行,并且图像显示正确原因,我看不到我在GUI上添加到应用程序中的WebKitBrowser - 任何人都有任何想法为什么会这样?我需要做些什么来显示它?

0 个答案:

没有答案