WPF: How to make canvas auto-resize?
问题 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