MrTy
MrTy

Reputation: 140

Change background as well as foreground in webBrowser Control ( windows phone 8)?

I'm a newbie, and I want to make a book app. I read file html in the Webbrowser (Windows Phone 8), but I want to change the background color to black and font color to white, but it is not working. I've tried following css,xaml.

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,10,14,-10"  Background="Black">
        <phone:WebBrowser x:Name="web" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top"  Width="446" Loaded="web_Loaded" Height="215" Background="Black" />

</Grid>

Upvotes: 0

Views: 870

Answers (1)

Romasz
Romasz

Reputation: 29792

It isn't possible as webbrowser engine renders a background color for HTML page. What you can use is a trick. As it is posted here, you can set default Opacity to 0, and when the load is completed, change the opacity to 1:

  <Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,10,14,-10"  Background="Black">
  <phone:WebBrowser x:Name="web" HorizontalAlignment="Left" Margin="10,0,0,0" VerticalAlignment="Top" 
                    Loaded="web_Loaded" Width="446" Height="215" Opacity="0" LoadCompleted="web_LoadCompleted"/>
  </Grid>

  private void web_LoadCompleted(object sender, NavigationEventArgs e)
  {
     web.Opacity = 1;
  }

Or as it is posted here you can cover webbrowser with another element which you collapse when content rendering is finished.

Upvotes: 1

Related Questions