Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3933822
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:38:41+00:00 2026-05-19T23:38:41+00:00

I have a WebBrowser embedded in tabcontrol in my WPF app as follows. <Grid>

  • 0

I have a WebBrowser embedded in tabcontrol in my WPF app as follows.

<Grid>
    <TabControl SelectionChanged="tabwindow_SelectionChanged">
        <TabItem Header="Preview" Name="PreviewWindow">
            <WebBrowser x:Name="PreviewBrowser" Loaded="PreviewBrowser_OnLoad"/>
        </TabItem>
        <TabItem Header="XML">
            <ew:CommonXmlEditor
                    x:Name="rawXmlEditor"
                    DataContext="{Binding ElementName=XMLDockMainWindow}"
                    ShowLineNumbers="True"
                    FontFamily="Consolas"
                    FontSize="10pt"
                    SyntaxHighlighting="XML"
                    ContextMenu="{StaticResource XmlEditorContextMenu}"/>
        </TabItem>
        <TabItem Header="Not Used">
            The Mushrooms Tab
        </TabItem>
    </TabControl>
</Grid> 

In tabwindow_SelectionChanged() event I am trying to update the contents of the browser as follows

   private void tabwindow_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        string previewFile = "/session/PreviewXml.data";
        XmlMethodCall.Instance.Put(previewFile, this.XmlEditor.Text, true);
        //WebBrowser browser = new WebBrowser();
        string urlForPreview = XmlMethodCall.Instance.ServerUri.ToString() + "/admin/framework/form_preview.php?path=" + previewFile;
        App app = Application.Current as App;
        string sessionState = XmlMethodCall.Instance.HttpResponse.Headers.Get("Cookie");
        int index = sessionState.IndexOf(";");
        if (index >= 0)
        {
            sessionState = sessionState.Substring(0, index);
        }
        sessionState = sessionState.Replace("ESPSessionState=", "");
        InternetSetCookie(XmlMethodCall.Instance.ServerUri.ToString() + "/admin/", "EspSessionId", sessionState);
        PreviewBrowser.Source = new Uri(urlForPreview);
        PreviewBrowser.Navigate(urlForPreview);
        bool isloa = PreviewBrowser.IsLoaded;
    }

However, the tabview always shows the first rendered screen of the webbrowser. I have to right click and say refresh on the tabview to see the updated contents of the webbrowser. On closer inspection the problem is tracked to the webbrowser which is not loaded even a different source is specified(or calling navigate(), refresh()….). On the previous code the boolean variable isloa is false.

Can someone throw some light into the issue. I see someone used a thread.sleep() as the last method in window_loaded to solve a similiar issue. Is there any better approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:38:42+00:00Added an answer on May 19, 2026 at 11:38 pm

    Jimmy, in my example below when you type some URI in Address text box and then switch to preview tab – browser content is loaded and rendered as usual.

    <TabControl SelectionChanged="TabControl_SelectionChanged">
        <TabItem Header="Preview" Name="PreviewWindow">
            <WebBrowser x:Name="PreviewBrowser" Loaded="PreviewBrowser_Loaded"/>
        </TabItem>
        <TabItem Header="XML">
            <TextBox Name="Address"/>
        </TabItem>
        <TabItem Header="Not Used">
            The Mushrooms Tab
        </TabItem>
    </TabControl>
    
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(Address.Text))
            {
                PreviewBrowser.Navigate("http://google.com");
            }
            else
            {
                PreviewBrowser.Navigate(Address.Text);
            }
        }
    

    I suppose the problem is in magic before line PreviewBrowser.Source. For example I could suppose that in your scenario URI does not changes (you just upload another data), so when you call Navigate nothing happened because browser could think that you are requesting the same page.

    Try to add to URI some parameter that varies from request to request, timestamp will be perfect (“http://server/?param1=x&param2=y&timestamp=”+DateTime.Ticks.ToString()).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms c# app that has an embedded webbrowser control inside it
Inside of my WPF application, I have embedded a WebBrowser control, which in turn
I have a Windows Forms WebBrowser control embedded in my application. Is there any
I have a Windows app that houses a web browser (Internet explorer) embedded in
I have a WPF application in which I have an embedded web browser control.
I have a WPF app. I need to embed a Silverlight app inside it.
I have written a basic Windows Form app in C# that has an embedded
we have embedded the .NET WebBrowser control (actually two in different tabs, if that
I have a C# WinForms app, which uses WebBrowser to display some UI elements
I am developing a Windows app with WebBrowser control ( IWebBrowser2 ) embedded. Things

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.