Web browser in scroll view

I have a simple wpf window in which there is a Scrollviewer and inside it there is a web browser.

<Window x:Class="WpfApplication9.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" Background="Gainsboro"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="100"/> <ColumnDefinition Width="300"/> </Grid.ColumnDefinitions> <ScrollViewer Width="300" Grid.Column="1" Height="200" HorizontalScrollBarVisibility="Auto"> <WebBrowser Width="400" Margin="2" Source="C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg" /> </ScrollViewer> </Grid> 

As I pointed out the width in the browser that is larger than the width of the Scroll Viewer, I expect the scroll viewer to show a horizontal scroll bar and show the web browser in the scroll viewer.

But when I horizontally scroll to the right, the web browser moves from the scroll widget.

Am I doing something wrong? Or is there a workaround for this?

Any help is greatly appreciated. Thanks.

+6
browser wpf scrollviewer
source share
1 answer

The WPF web browser control is actually an ActiveX component, so it doesn’t work well with the rest of the framework. As far as I can tell, the browser sticks on top of your application, and you will always see it all, regardless of the base container.

Instead, you can try using something like WPF Chromium .

+1
source share

All Articles