0

I'm starting to learn how to program and I have a problem.
I am making an application in C # WPF.
I want to put a scrollbar on a grid and not activate it.
I searched and tried several things I found, but I have not gotten it right.
As the window is larger than the monitor, what I want is to put a scrollbar to access the bottom of the window.
The last thing I tried is this.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="921*" />
        <RowDefinition Height="0*" />
    </Grid.RowDefinitions>
    <ScrollBar Height="921" HorizontalAlignment="Left" Margin="761,0,0,0" Name="scrollBar1" 
               VerticalAlignment="Top" Width="12" Maximum="960" Minimum="1" SmallChange="1" />
</Grid>

With this comes the scrollbar, but the window does not move. Thanks in advance and forgive for writing. I made it with google translator.

4

1 回答 1

1

您希望滚动的内容应该是ScrollViewer的子项。

<ScrollViewer>
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="921*" />
        <RowDefinition Height="0*" />
    </Grid.RowDefinitions>
</Grid>
</ScrollViewer>

出于布局的目的,假设孩子具有无限的可用宽度和高度。这意味着滚动查看器的子项将永远不会像在空间受限时那样运行(除非您设置 maxwidth / maxheight)。

于 2013-08-20T07:25:45.637 回答