0

我有一个比它的窗口容器大的图像,它被放置在一个 ScrollViewer 中,但是,图像根本不滚动。我尝试将图像放入容器中,但没有成功。我在这里缺少什么设置?(我直接从 MS 复制了代码,但他们错了)

这是代码:

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:h="http://helixtoolkit.codeplex.com" x:Class="TileLayout"
Title="TileLayout" Height="1000" Width="845" WindowStartupLocation="CenterScreen" WindowStyle="ThreeDBorderWindow">
<StackPanel HorizontalAlignment="center" VerticalAlignment="Top">
    <StackPanel Orientation="Horizontal"   >
        <TextBox x:Name="txtSourceFilePath" Width="500" Margin="10" Height="22" TextChanged="TextBox_TextChanged" Text="E:\projects\Test3D\SavedSnapshots\snapshot.png"/>
        <Button x:Name="btnPickFile" Width="100" Margin="0,10,10,10" Content="Pick File" ></Button>
    </StackPanel>
    <ScrollViewer VerticalScrollBarVisibility="Auto" >
        <Image x:Name="imgFinal" Source="SteelMotion_chevron2.png"/>
    </ScrollViewer>
</StackPanel>

4

2 回答 2

2
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:h="http://helixtoolkit.codeplex.com" x:Class="TileLayout"
Title="TileLayout" Height="1000" Width="845" WindowStartupLocation="CenterScreen" WindowStyle="ThreeDBorderWindow">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="50"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <StackPanel Orientation="Horizontal" Height="50"  HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="0">
        <TextBox x:Name="txtSourceFilePath" Width="500" Margin="10" Height="22" TextChanged="TextBox_TextChanged" Text=""/>
        <Button x:Name="btnPickFile" Width="100" Margin="0,10,10,10" Content="Pick File" ></Button>
    </StackPanel>
    <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" >
        <Image x:Name="imgFinal" Source="SteelMotion_chevron2.png" Width="768" Height="1408"/>
    </ScrollViewer>

</Grid>

于 2013-11-14T04:58:32.043 回答
0

您需要指定 ScrollViewer 的大小。在这种情况下 ScrollViewer 和 Image 大小相同,因此滚动条不显示。

于 2013-11-14T07:02:51.613 回答