Search code examples
iframestackpanelxbapwindowsformshost

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


i have developed a windows form c# desktop applicaion, ii want to see this in browser, thats why i include it in wpf bowser app, using windows form host, now i can see it in browser, then i showed that xbap in asp.net iframe.

iframe is <iframe name="I1" id="I1" runat =server ></iframe> stack panel in wpf <StackPanel Height="201" HorizontalAlignment="Left" Name="stackPanel1" VerticalAlignment="Top" Width="223" Background="#FFCECECE">

setting windows form host is like...

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);

now there is a header coming having forward and back button, how to remove iti want to hide the portion which is in red circle


Solution

  • Hide Navigation UI (back, forward button) of Xbap application Xbap application can be used directly in browser or can be used in a iframe in a web page. when you use directly in browser, browsers nagivation ui is used as xbap navigation UI . But if you use xbap in a iframe xbap host automatically add two back forward button and add a navigation header to your xbap application. if you are using the xbap in a existing web page and in a iframe this cause a little bit problem.

    but we can hide the navigation ui very easyly... all we have to do is to set the wpf page object's ShowsNavigationUI property to false... thats all... you are done. But if you are using an "user control" as startup object there is no way to set the property. This works only in case of WPF Page project item template.

    But you can still hide the navigation UI... on application's contractor subscribe the navigated event ..

    public App()
    {
    this.Navigated += new NavigatedEventHandler(App_Navigated);
    }
    
    void App_Navigated(object sender, NavigationEventArgs e)
    {
    NavigationWindow ws = (e.Navigator as NavigationWindow);
    ws.ShowsNavigationUI = false;
    }