简体   繁体   中英

Awesomium for WPF does not render unless window is resized

I just installed Awesomium for the first time (V 1.7.4.2).

I was excited to find a way to inter-op with web content in my WPF app. I fired it up and was a bit disappointed. My first simple WPF smoke test failed.

I tried the following code:

 <Window
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:awe="http://schemas.awesomium.com/winfx" 
       x:Class="WpfAndSpa.MainWindow">
   <Grid>
       <awe:WebControl  x:Name="WebControl" Source="http://google.com"/>
   </Grid>
</Window>

And I got a blank screen.

Playing around with it revealed that by resizing the window, the web page would render.

Is there an automatic way to get the content to render? (Clearly I cannot be asking my users to resize the screen each time I want to load a page.)

Note: I tried the Awesomium sample "WpfWebControlSample" and it has the same problem.

UPDATE : The screen is a static screen. So if you resize it and get Google.com, if you type in the search box you don't see your text and you can't see the results unless you resize the screen again.

This one just about kills Awesomium for me. Anyone know of something similar?

So I figured this one out. It is not a bug in Awesomium. (Though I think it should be on a quick start page.)

Awesomium supports two view modes. Offscreen and Windowed.

Offscreen is something that very manual. All input goes through you. (Why the default events don't still fire is kind of odd). I think this is the mode you will end up using if you want to interact with your HTML.

But if you want a normal imbedded browser window then you need to turn on the Window view mode.

Here is an updated example:

<Window
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:awe="http://schemas.awesomium.com/winfx" 
       x:Class="WpfAndSpa.MainWindow">
   <Grid>
       <awe:WebControl x:Name="WebControl"
                       ViewType="Window"       <--------------+
                       Source="http://google.com"/>           |
   </Grid>                                                    |
</Window>                                                     |
                                                              |
This part is new ---------------------------------------------+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM