1

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

在模拟器中,页面不滚动。如果我滚动按住鼠标按钮,然后它会滚动,但释放鼠标按钮后会恢复到原来的状态....请帮助任何人....在此致谢!

4

1 回答 1

3

没有提到滚动查看器内的堆栈面板的高度。仅当滚动查看器内的控件超过其高度时才支持滚动。因此,您最好将滚动查看器和堆栈面板的高度设置为 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>

试试这个效果很好

于 2012-05-28T09:05:21.540 回答