How to add Scrollbars to Grid How to add Scrollbars to Grid wpf wpf

How to add Scrollbars to Grid


Usually you can wrap the element with <ScrollViewer> or set ScrollViewer.HorizontalScrollBarVisibility and ScrollViewer.VerticalScrollBarVisibility inside the element's XAML. I like setting to Auto, so that they show up only when needed.

Just try this to start:

<ScrollViewer>  <Grid>  // some code  </Grid></ScrollViewer>

EDIT for further help! Here's an example of a better layout, the listview is on the left followed by the two canvases. You may want to put these above each other or have a different layout, but this will show you how to do it:

<Grid>    <Grid.RowDefinitions>        <RowDefinition Height="Auto" />        <RowDefinition Height="*" />    </Grid.RowDefinitions>    <Menu Name="menu1" >        <MenuItem Header="File">            <MenuItem Command="ApplicationCommands.New" Header="New" />            <MenuItem Command="ApplicationCommands.Save" Header="Save" />            <MenuItem Command="ApplicationCommands.Open" Header="Open" />            <MenuItem Command="ApplicationCommands.Close" Header="Exit" />        </MenuItem>        <MenuItem Header="Stuff">            <MenuItem Header="Properties" Command="Properties"/>            <MenuItem Header="Tileset" Command="Replace"/>        </MenuItem>    </Menu>    <Grid Grid.Row="1">        <Grid.ColumnDefinitions>            <ColumnDefinition />            <ColumnDefinition />            <ColumnDefinition />        </Grid.ColumnDefinitions>        <ListView />        <Canvas Grid.Column="1"/>        <Canvas Grid.Column="2"/>    </Grid></Grid>