2

I am using WebBrowser control in my application like:

<WebBrowser x:Name="wcPlayback" Visibility="Visible" LoadCompleted="wcPlayback_LoadComplete" Margin="0,-4,0,0" Width="960px" Height="619px" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"></WebBrowser>

I did many tries to remove scrollbar but failed.

Please help me.

azharmalik3
  • 553
  • 8
  • 21

4 Answers4

9

In case you can modify the web page you want to load, just modify the body tag as below:

<body scroll="no">

It worked for me.

Follow this link for more details: https://social.msdn.microsoft.com/Forums/vstudio/en-US/a64e2247-c726-473e-bed2-12a2b4454ede/how-to-show-hide-scrollbars-in-new-35-sp1-beta-wpf-webbrowser-control?forum=wpf

Khoa Nguyen
  • 101
  • 2
  • 3
8

I used this code and worked for me:

<WebBrowser LoadCompleted="wb_LoadCompleted"></WebBrowser>           

void wb_LoadCompleted(object sender, NavigationEventArgs e)
{
    string script = "document.body.style.overflow ='hidden'";
    WebBrowser wb = (WebBrowser)sender;
    wb.InvokeScript("execScript", new Object[] { script, "JavaScript" });
}

[edit]

The point is, you need to set overflow: hidden; in your page css. The code above is doing it.

Nickon
  • 9,652
  • 12
  • 64
  • 119
4

In my case, script from Nickon's answer abow, does not work:

string script = "document.body.style.overflow ='hidden'" // Does not work;

but this works:

string script = "document.documentElement.style.overflow ='hidden'" //Work for me;
LeffBA
  • 51
  • 1
  • 4
0

I used this to change the body string directly:

wcPlayback.Document.Body.scroll = "no";
HackSlash
  • 4,944
  • 2
  • 18
  • 44