Mushfiq
Mushfiq

Reputation: 769

Scroll viewer in Windows phone 7 not working

I'm new in windows phone 7 development. I've started an app where i used scroll viewer. Here is my code : <Grid.RowDefinitions> </Grid.RowDefinitions>

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

In Emulator the page is not scrolling. If i scroll holding mouse button then it scrolls but goes back to it's original state after releasing the mouse button.

Upvotes: 1

Views: 1622

Answers (1)

SENTHIL KUMAR
SENTHIL KUMAR

Reputation: 647

The height of the stackpanel inside the scrollviewer is not mentioned. The scrolling supports only when the controls inside the scroll viewer is more than than its height. So you better set the height of the scroll viewer and stackpanel as 1500 or something as you need.

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

Try this it works fine

Upvotes: 3

Related Questions