ScrollView Windows手机的问题

时间:2014-02-26 14:49:10

标签: xaml mvvm windows-phone-8 scrollviewer

我刚刚开始为Windows Phone 8开发。我在使用ScrollViewer控制器时遇到了问题。它最初工作,但现在当我单击并拖动到面板的底部时,我可以看到内容,直到我释放单击,然后它弹回到视图的顶部。

我尝试删除动画,并尝试使用固定的堆栈面板高度。我也尝试过使用不同的网格行。可能有语法错误吗?这是xaml文件的片段,非常感谢任何帮助:

    <Grid x:Name="LayoutRoot"
    Background="#FFDBDBDB">
    <i:Interaction.Triggers>
        <i:EventTrigger>
            <eim:ControlStoryboardAction Storyboard="{StaticResource PageViewAnimation}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" MinHeight="100" />
    </Grid.RowDefinitions>

    <StackPanel x:Name="TitlePanel"
        Grid.Row="0"
        Margin="12,0,0,0" Height="Auto" VerticalAlignment="Top">
        <Image x:Name="image1" Height="100" Source="/Assets/Logo/Logo.png" HorizontalAlignment="Left"/>

    <ScrollViewer x:Name="scrollViewer" Grid.Row="1">
        <StackPanel x:Name="ContentPanel"
                VerticalAlignment="Top" Margin="12,0,0,0">

            <!--CurrentJob-->
            <Image x:Name="image" Stretch="UniformToFill" Margin="0,0,12,0" VerticalAlignment="Top" Source="{Binding BusinessCardImage}" RenderTransformOrigin="0.5,0.5">
                <Image.RenderTransform>
                    <CompositeTransform/>
                </Image.RenderTransform>
            </Image>

            <!--CurrentJob-->
            <TextBlock x:Name="currentJobLbl" HorizontalAlignment="Left" TextWrapping="Wrap" Text="Current Job" VerticalAlignment="Top" Margin="12,0,0,0"/>
            <TextBox x:Name="currentJobTxt" 
                TextWrapping="Wrap" 
                Text="{Binding CurrentJob, Mode=TwoWay}" 
                VerticalAlignment="Top"
                AcceptsReturn="True"
                Visibility="{Binding IsEditMode, Converter={StaticResource TrueToVisibleConverter}}"/>
            <TextBlock x:Name="currentJobTextBlock"
                TextWrapping="Wrap" 
                Text="{Binding CurrentJob, Mode=TwoWay}" 
                VerticalAlignment="Top"
                RenderTransformOrigin="0.5,0.5"
                Visibility="{Binding IsEditMode, Converter={StaticResource FalseToVisibleConverter}}"/>

            <!--Websites-->
            <TextBlock x:Name="websitesLbl" HorizontalAlignment="Left" Margin="12,0,0,0" TextWrapping="Wrap" Text="Websites" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
                <TextBlock.RenderTransform>
                    <CompositeTransform/>
                </TextBlock.RenderTransform>
            </TextBlock>
            <TextBox x:Name="websitesTxt"
                TextWrapping="Wrap" 
                Text="{Binding Websites, Mode=TwoWay}" 
                VerticalAlignment="Top"
                AcceptsReturn="True" RenderTransformOrigin="0.5,0.5"
                Visibility="{Binding IsEditMode, Converter={StaticResource TrueToVisibleConverter}}">
                <TextBox.RenderTransform>
                    <CompositeTransform/>
                </TextBox.RenderTransform>
            </TextBox>
            <TextBlock x:Name="websitesTextBlock"
                TextWrapping="Wrap" 
                Text="{Binding Websites, Mode=TwoWay}" 
                VerticalAlignment="Top"
                RenderTransformOrigin="0.5,0.5"
                Visibility="{Binding IsEditMode, Converter={StaticResource FalseToVisibleConverter}}">
                <TextBlock.RenderTransform>
                    <CompositeTransform/>
                </TextBlock.RenderTransform>
            </TextBlock>

                <Grid>
                    <Button x:Name="editSaveBtn" 
                        Content="{Binding EditSaveButtonText, Mode=TwoWay}" 
                        HorizontalAlignment="Center"
                        VerticalAlignment="Top" 
                        Width="150">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click" SourceName="editSaveBtn">
                                <Command:EventToCommand x:Name="InvokeEditModeCommand"
                                    Command="{Binding InvokeEditModeCommand, Mode=OneWay}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
            </StackPanel>
    </ScrollViewer>
    </StackPanel>
</Grid>

1 个答案:

答案 0 :(得分:0)

尝试将网格行定义更改为:

<Grid.RowDefinitions>
    <RowDefinition Height="Auto" MinHeight="100" />
    <RowDefinition Height="*" />
</Grid.RowDefinitions>