簡體   English   中英

ScrollViewer不會滾動圖像WPF

[英]ScrollViewer does not scroll Image WPF

我有一個比它的窗口容器大的圖像,它被放置在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>

<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>

您需要指定ScrollViewer的大小。 在這種情況下,ScrollViewer和Image的大小相同,因此滾動條不會顯示。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM