I would like my canvas to automatically resize to the size of its items, so that the ScrollViewer scroll bars have the correct range. Can this be done in XAML?
<ScrollViewer HorizontalScrollBarVisibility="Auto" x:Name="_scrollViewer">
<Grid x:Name ="_canvasGrid" Background="Yellow">
<Canvas x:Name="_canvas" HorizontalAlignment="Left" VerticalAlignment="Top" Background="Green"></Canvas>
<Line IsHitTestVisible="False" .../>
</Grid>
</ScrollViewer>
In the above code the canvas always has size 0, though it doesn't clip its children.