Ask a questionAsk a question
 

AnswerWebBrowser as VisualBrush ?

  • Thursday, August 21, 2008 7:11 AMEpsilone3 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    HI first :

    Hi I try to catch my 

    LoadCompleted event and i can't success any suggestions ?

    <Grid>

    <WebBrowser x:Name="WebBrowserTest" Loaded="WebBrowser_Loaded"  

    LoadCompleted="wb_LoadCompleted"

    ClipToBounds="True" />

    </Grid>

    </UserControl>

     
    Code behind :





    private void WebBrowser_Loaded(object sender, RoutedEventArgs e)

    {

    WebBrowser wb = sender as WebBrowser;

    // wb.LoadCompleted += new LoadCompletedEventHandler(wb_LoadCompleted);//something i try.


    wb.Source =
    new Uri ( http://www.google.com, UriKind.RelativeOrAbsolute);

    }

    void wb_LoadCompleted(object sender, NavigationEventArgs e)

    {

    throw new NotImplementedException(); // also a break point //

    }

    The final use of the WebBrowser in as a resource.

    and i can't find the way to use webbrowser as visualbrush ?

    Thanks.


    Debug your life !. http://epsilone3.spaces.live.com
    • Edited byEpsilone3 Thursday, August 21, 2008 7:12 AMSpelling
    • Edited byEpsilone3 Thursday, August 21, 2008 7:56 AMadding
    • Edited byEpsilone3 Thursday, August 21, 2008 12:01 PMadding
    • Edited byEpsilone3 Friday, August 22, 2008 5:31 PMCaptital
    •  

Answers

  • Thursday, August 21, 2008 9:28 PMRobJH Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Tim,  that's not strictly true. You can use a windows forms web browser as the source of a visual in WPF.
    although I suspect it would now be infinately easier using 3.51 than the nasty device context twiddling I did.
    more details of the WinForms version is on my blog (its pretty old now and was a proof of concept - putting Virtual Earth on a WPF form) but that should be a lot easier now.

    here :

    http://rob.runtothehills.org/archives/60

    I was meaning to do the same with 3.51, but just don't have the time at the moment! :(

    cheers
    Rob


    --Rob :::::: Visit -> http://rob.runtothehills.org
    • Proposed As Answer byMarco Zhou Tuesday, August 26, 2008 10:00 AM
    • Marked As Answer byMarco Zhou Wednesday, August 27, 2008 10:33 AM
    •  

All Replies

  • Thursday, August 21, 2008 8:54 PMTim DawsonMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     A WebBrowser hosts an HWND. You can't use it as the source for a Visual Brush.
    Controls for WPF and Windows Forms at http://www.divelements.co.uk
  • Thursday, August 21, 2008 9:05 PMEpsilone3 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    So if use the webbrowser from the netframe 3.5 sp1 , does it still can't be display inside a visualbrush ?.
    Debug your life !. http://epsilone3.spaces.live.com
    • Edited byEpsilone3 Thursday, August 21, 2008 9:30 PMlokm
    •  
  • Thursday, August 21, 2008 9:28 PMRobJH Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Tim,  that's not strictly true. You can use a windows forms web browser as the source of a visual in WPF.
    although I suspect it would now be infinately easier using 3.51 than the nasty device context twiddling I did.
    more details of the WinForms version is on my blog (its pretty old now and was a proof of concept - putting Virtual Earth on a WPF form) but that should be a lot easier now.

    here :

    http://rob.runtothehills.org/archives/60

    I was meaning to do the same with 3.51, but just don't have the time at the moment! :(

    cheers
    Rob


    --Rob :::::: Visit -> http://rob.runtothehills.org
    • Proposed As Answer byMarco Zhou Tuesday, August 26, 2008 10:00 AM
    • Marked As Answer byMarco Zhou Wednesday, August 27, 2008 10:33 AM
    •  
  • Friday, August 22, 2008 1:02 AMEpsilone3 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Trying to :

    <Grid Name="GridVisualBrush" ClipToBounds="True">

    <Grid.Background>

    <VisualBrush>

    <VisualBrush.Visual>

    <WebBrowser Source ="http://www.msn.com"/>

    </VisualBrush.Visual>

    </VisualBrush>

    </Grid.Background>

    </Grid>

    With no luck.
    Any suggestion guys ?


    Debug your life !. http://epsilone3.spaces.live.com
  • Wednesday, August 27, 2008 6:48 PMRobJH Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Epsilone3,
        I've just tried a quick example project with a web browser control from 3.5sp1 and it doesn't seem to want to be uses as the source for a visual brush at all. No amount of fiddling calling refresh methods etc will get it to show up.
    I suspect that there's some wpf trickery going on behind the scenes here and it's still just a winforms browser in WPF clothing.

    unless of course, any of the MS guys know better ;)

    cheers,
    Rob


    --Rob :::::: Visit -> http://rob.runtothehills.org
  • Wednesday, August 27, 2008 7:44 PMJeremiah Morrill Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I think this is a good example of why decent DWM access would be so powerful.  If we could use a DWM texture as a VisualBrush, we could surely do some cool stuff with Win32 (hWnd) controls.

    -Jer
  • Friday, September 05, 2008 8:38 AMJan Kučera Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi, I would like to retrun to the first question - me too can't get the LoadCompleted event. Anybody knows the answer? Or is it a bug?

    Thanks!
    Jan