Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Browser Within A Scroll Viewer

I have a simple wpf window which has a Scrollviewer and inside it 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 have given a Width to the browser which is more than the width of the Scroll Viewer i expect the scroll viewer to show the horizontal scroll bar and show the web browser within the Scroll Viewer.

But when i horizontally scroll to the right , the web browser moves out of the scroll viwer.

Am i doing something wrong? Or is there any workaround for this?

Any help is highly appreciated. Thanks.

like image 761
user501579 Avatar asked Mar 09 '11 07:03

user501579


1 Answers

The WPF web browser control is actually an ActiveX component so it doesn't quite play nice with the rest of the framework. As far as I can tell, the browser gets pasted on top of your application and you will always see all of it, regardless of the underlying container.

You could try to use something like WPF Chromium instead.

like image 101
Tiberiu Ana Avatar answered Oct 01 '22 05:10

Tiberiu Ana