locked
Frame inside a ScrollViewer RRS feed

  • Question

  • Hi Folks,

    I'd like to use a frame within a ScrollViewer and keep the frame smaller than the ScrollViewer. If I try the obvious solution:

    <Window x:Class="FrameInScrollviewer.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Grid>
            <ScrollViewer
                Height="50">
                <Frame
                Source="http://www.google.com" />
            </ScrollViewer>
        </Grid>
    </Window>
    The frame spills out of the ScrollViewer. Does anyone know how to make this fit?

    Thanks,
    Adam Cataldo
    Friday, April 10, 2009 7:25 PM

Answers

  • Hi Adam,

    setting the Frames Height also to 50 will work.

    	<Grid>
    		<ScrollViewer Height="50">
    			<Frame Height="50" Source="http://www.google.com" />	
    		</ScrollViewer>
    	</Grid>

    Hope that helps.

    • Marked as answer by Tao Liang Tuesday, April 14, 2009 3:04 AM
    Friday, April 10, 2009 8:29 PM
  • Frame uses a Win32 window to embed the browser.  WPF has some limitations around interacting with embedded Win32 windows so it cannot be clipped by the scroll viewer.  The Frame should have it's own scrollbar for scrolling the page so you should be able to put it directly in a panel & bind the frames height to the panels height.  You don't need your own ScrollViewer.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Tao Liang Tuesday, April 14, 2009 3:03 AM
    Friday, April 10, 2009 8:42 PM

All replies

  • Hi Adam,

    setting the Frames Height also to 50 will work.

    	<Grid>
    		<ScrollViewer Height="50">
    			<Frame Height="50" Source="http://www.google.com" />	
    		</ScrollViewer>
    	</Grid>

    Hope that helps.

    • Marked as answer by Tao Liang Tuesday, April 14, 2009 3:04 AM
    Friday, April 10, 2009 8:29 PM
  • Frame uses a Win32 window to embed the browser.  WPF has some limitations around interacting with embedded Win32 windows so it cannot be clipped by the scroll viewer.  The Frame should have it's own scrollbar for scrolling the page so you should be able to put it directly in a panel & bind the frames height to the panels height.  You don't need your own ScrollViewer.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Tao Liang Tuesday, April 14, 2009 3:03 AM
    Friday, April 10, 2009 8:42 PM
  • Thanks guys!
    Wednesday, April 22, 2009 12:44 AM