【问题标题】:Scroll viewer in Windows phone 7 not workingWindows phone 7 中的滚动查看器不起作用
【发布时间】:2012-05-28 08:44:37
【问题描述】:

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

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

【问题讨论】:

    标签: windows-phone-7 scrollviewer


    【解决方案1】:

    没有提到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>
    

    试试这个效果很好

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-16
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      相关资源
      最近更新 更多