我正在努力显示 UI 元素上方ScrollViewer。这应该是非常简单的,但事实并非如此。我希望这段代码能够工作:
<Grid>
<Button>A</Button>
<ScrollViewer ZoomMode="Enabled" x:Name="Scroller">
<Viewbox>
<Rectangle Width="200" Height="200" Fill="White"/>
</Viewbox>
</ScrollViewer>
<Button>B</Button>
</Grid>
但是当我放大 ScrollViewer 时,它显示在两个按钮的顶部。
请尝试为网格设置RowDefinitions并将UIElements放入不同的行中。
Xaml:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Button Grid.Row="0">A</Button>
<ScrollViewer Grid.Row="1" ZoomMode="Enabled" x:Name="Scroller">
<Viewbox>
<Rectangle Width="200" Height="200" Fill="White"/>
</Viewbox>
</ScrollViewer>
<Button Grid.Row="2">B</Button>
</Grid>