locked
Scroll Viewer not responding to runtime change of elements within it RRS feed

  • Question

  • I have placed a canvas inside a scroll viewer. I then increase the canvas height and width during runtime using matrix transformation. My problem is that , once i have resized the canvas the scroll viewer no longer scrolls the entire canvas.           

     How could i solve this?

     <ScrollViewer Grid.Row="1" Grid.Column="1" x:Name="ScrollViewer" BorderThickness="0" HorizontalScrollBarVisibility="Visible" >

    <Canvas VerticalAlignment="Top" HorizontalAlignment="Left" Width="900" Height="700" x:Name="ToZoom" >

    <Rectangle Canvas.Left="700" Canvas.Top="400" Fill="Black" Width="100" Height="100"></Rectangle>

     

    </Canvas>

    </ScrollViewer>

    Tuesday, June 16, 2009 7:20 AM

Answers

  • Things like ScaleTransform and MatrixTransform don't participate in the sizing of a control for layout. You'll probably have to wrap it with some other control like a Border and set its width and height manually to get the results you're looking for. Another option would be to not use ScrollViewer and use your own scrollbars to handle scrolling yourself.

    Tuesday, June 16, 2009 12:27 PM

All replies

  •  I'm really not sure about that but did you try ScrollViewer1.UpdateLayout() ?

    Tuesday, June 16, 2009 7:41 AM
  • ya i did try .. the problem is scroll viewer is behaving as though the canvas is the initial size itself even after it is increased at runtime ..

    Tuesday, June 16, 2009 9:42 AM
  • Things like ScaleTransform and MatrixTransform don't participate in the sizing of a control for layout. You'll probably have to wrap it with some other control like a Border and set its width and height manually to get the results you're looking for. Another option would be to not use ScrollViewer and use your own scrollbars to handle scrolling yourself.

    Tuesday, June 16, 2009 12:27 PM