如何删除 header 的 ifram/Windows 主机 Control/Stack 面板

how to remove header of ifram/Windows Host Control/Stack panel

我开发了一个 windows 形式的 c# 桌面应用程序, 我想在浏览器中看到它,这就是为什么我将它包含在 wpf bowser 应用程序中,使用 windows 表单主机,现在我可以在浏览器中看到它, 然后我在 asp.net iframe 中展示了 xbap。

iframe 是 <iframe name="I1" id="I1" runat =server ></iframe> wpf 中的堆栈面板 <StackPanel Height="201" HorizontalAlignment="Left" Name="stackPanel1" VerticalAlignment="Top" Width="223" Background="#FFCECECE">

设置 windows 表单主机就像...

stackPanel1.Width = mfrm.Width;
            stackPanel1.Height = mfrm.Height;
            windowsformhost.Width = mfrm.Width;
            windowsformhost.Height = mfrm.Height;
             mfrm.TopLevel = false;
            windowsformhost.Child = mfrm;

            stackPanel1.Children.Add(windowsformhost);

现在有一个 header 有 前进后退 按钮,如何删除它

隐藏 Xbap 应用程序的导航 UI(后退、前进按钮) Xbap 应用程序可以直接在浏览器中使用,也可以在网页中的 iframe 中使用。当您直接在浏览器中使用时,浏览器 nagivation ui 用作 xbap 导航 UI 。但是,如果您在 iframe 中使用 xbap,xbap 主机会自动添加两个后退按钮并向您的 xbap 应用程序添加一个导航 header。如果您在现有网页和 iframe 中使用 xbap,这会导致一些问题。

但我们可以很容易地隐藏导航 ui...我们所要做的就是设置 wpf 页面 object 的 ShowsNavigationUI 属性假...仅此而已...您完成了。但是,如果您使用 "user control" 作为启动 object,则无法设置 属性。这仅适用于 WPF 页面项目项模板。

但您仍然可以隐藏导航 UI...在应用程序的承包商上订阅导航事件..

public App()
{
this.Navigated += new NavigatedEventHandler(App_Navigated);
}

void App_Navigated(object sender, NavigationEventArgs e)
{
NavigationWindow ws = (e.Navigator as NavigationWindow);
ws.ShowsNavigationUI = false;
}