RadModalWindow.WindowOpened event not working correctly with WebBrowser control in it?

2 posts, 0 answers
  1. runtastic
    runtastic avatar
    7 posts
    Member since:
    Jan 2011

    Posted 25 Feb 2011 Link to this post

    Is it possible that RadModalWindow.WindowOpended event is fired to early?

    Basically what I'm trying to do is navigate to an URL every time the window is opened. So I used WindowOpended event to do that. But I'm getting an exception: "You cannot call WebBrowser methods until it is in the visual tree."

    Take a look at the following code:

    RadModalWindow window;
    WebBrowser browser;
    private void button_Click(object sender, RoutedEventArgs e)
        if (window == null)
            window = new RadModalWindow();
            browser = new WebBrowser();
            window.Content = browser;
            window.WindowOpened += new EventHandler<EventArgs>(window_WindowOpened);
        window.IsOpen = true;
    void window_WindowOpened(object sender, EventArgs e)
        // always navigate to the same url when opening the window
        browser.Navigate(new Uri("http://www.google.com"));

    Currently I have a workaround using a Timer that will fire after 250 ms and then call browser.Navigate(). That works fine. But it would be great if this will work without a timer.
  2. Victor
    Victor avatar
    1349 posts

    Posted 01 Mar 2011 Link to this post

    Hello Buju,

     Thank you for writing.

    We will consider the behavior of the WindowOpened event. In the mean time, you can use Dispatcher.BeginInvoke() instead of the timer. For example:

    browser.Dispatcher.BeginInvoke(() => browser.Navigate(new Uri("http://www.google.com")));

    Please write again if you have other questions or issue you would like to report. 

    All the best,
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
Back to Top