Windows Phone 7中的滚动查看器无法正常工作

时间:2012-05-28 08:44:37

标签: windows-phone-7 scrollviewer

我是windows phone 7开发的新手。我开始使用滚动查看器的应用程序。这是我的代码:                                                                                   

        <!--TitlePanel contains the name of the application and page title-->


        <!--ContentPanel - place additional content here-->
        <ScrollViewer>                
            <StackPanel Margin="0,150,0,0">
                <toolkit:PhoneTextBox Hint="UserName" Name="txtUsername" Width="auto" HintStyle="{StaticResource HintCustomStyle}" LengthIndicatorVisible="True" DisplayedMaxLength="6" ></toolkit:PhoneTextBox>
                <toolkit:PhoneTextBox Name="txtFname" Hint="First Name" Width="auto" HintStyle="{StaticResource HintCustomStyle}" LengthIndicatorVisible="True" DisplayedMaxLength="20"></toolkit:PhoneTextBox>
                <toolkit:PhoneTextBox Name="txtLastName" Hint="Last Name" Width="auto" HintStyle="{StaticResource HintCustomStyle}" LengthIndicatorVisible="True" DisplayedMaxLength="20"></toolkit:PhoneTextBox>
                <toolkit:PhoneTextBox Hint="Password" Name="txtPassword" Width="auto" HintStyle="{StaticResource HintCustomStyle}" LengthIndicatorVisible="True" DisplayedMaxLength="6" ></toolkit:PhoneTextBox>
                <toolkit:PhoneTextBox Hint="Cofirm Password" Name="txtConfirmPassword" Width="auto" HintStyle="{StaticResource HintCustomStyle}" LengthIndicatorVisible="True" DisplayedMaxLength="6" LostFocus="txtConfirmPassword_LostFocus"></toolkit:PhoneTextBox>
                <toolkit:PhoneTextBox Hint="Emplyee ID" Name="txtEmployeeID" Width="auto" HintStyle="{StaticResource HintCustomStyle}" LengthIndicatorVisible="True" DisplayedMaxLength="6"></toolkit:PhoneTextBox>
                <Button Content="Create QR Code and Sign Up" Name="btnCreateQR" Width="auto" Click="btnCreateQR_Click">
                    <Button.Background>
                        <ImageBrush ImageSource="\assests\backgroungimages\btnImage.jpg" Stretch="UniformToFill"></ImageBrush>
                    </Button.Background>
                </Button>
            </StackPanel>
        </ScrollViewer>
    </Grid>

</Grid>

在模拟器中,页面不滚动。如果我滚动按住鼠标按钮然后滚动但在释放鼠标按钮后返回到它的原始状态.... 请帮助任何人......先谢谢你们!

1 个答案:

答案 0 :(得分:3)

未提及scrollviewer内的stackpanel的高度。仅当滚动查看器内的控件高于其高度时,滚动才会支持。因此,您可以根据需要将滚动查看器和堆栈面板的高度设置为1500或更高。

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" Background="Black">
        <ScrollViewer Height="1500">
            <StackPanel Height="1500" Margin="0,150,0,0">
                <TextBox  Name="txtUsername" Width="auto" />
                <TextBox Name="txtFname"  Width="auto"/>
                <TextBox Name="txtLastName"  Width="auto" />
                <TextBox  Name="txtPassword" Width="auto" />
                <TextBox  Name="txtConfirmPassword" Width="auto" />
                <TextBox  Name="txtEmployeeID" Width="auto" />

            </StackPanel>
        </ScrollViewer>
    </Grid>

试试这个工作正常