我試圖在Canvas
內使用ScrollViewer
,但滾動不起作用。ScrollViewer無法在Canvas中工作
<Page
x:Class="ScrollViewerInCanvas.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ScrollViewerInCanvas"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Canvas>
<ScrollViewer>
<StackPanel Orientation="Vertical" Width="400">
<TextBlock Text="Just a huge text that will not fit into a single frame"
FontSize="100" TextWrapping="WrapWholeWords" />
</StackPanel>
</ScrollViewer>
</Canvas>
</Grid>
</Page>
但是如果我切換Canvas
與Grid
一切正常。有沒有辦法讓ScrollViewer
在Canvas
裏面工作?
@PeterDuniho這實際上是最小的例子,再現我的問題。我對Canvas如何工作的誤解是問題的根源。你對我的問題的回答實際上正是我所需要的。請移動你的部分答案,你描述了Canvas如何工作到「答案」,我會將其標記爲我的問題的答案。 – Geslot
好的,完成了。請注意我編輯到您的問題中的代碼示例。這是預期的那種代碼示例,以確保對問題的容易理解和可重複性。有關更多詳細信息,請參閱[mcve](包括該文末尾的鏈接)。 –