I have added a ScrollViewer object on my application page and I have added many control objects on the ScrollViewer object but the end-user using the app can not view all the elements because the Scroll does not scroll low enough, and the page keeps returning to it's original position before the user has the opportunity to enter any information.
Here is my XAMLCode :
<phone:PhoneApplicationPage
x:Class="WinHomeWork2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="VOLKOV LTD" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="Agent_App" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<ScrollViewer
Name="mainScrollViewer"
Margin="0,175,0,0"
VerticalScrollBarVisibility="Visible" AllowDrop="False" ManipulationMode="Control">
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
<RowDefinition Height="300*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="200*"/>
</Grid.ColumnDefinitions>
<TextBox
Name="AgentName"
Height="80"
Grid.Row="0"
Grid.Column="3"
/>
<TextBlock
Name="AgentNameTextBlock"
FontSize="25"
Text="Agent Name"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="1"
/>
<TextBlock
Name="PasswordTextBlock"
Grid.Row="1"
Grid.Column="0"
Text="Password"
FontSize="25"
/>
<PasswordBox
Name="Agent_Password"
Height="80"
Grid.Row="1"
Grid.Column="3"
/>
<CheckBox
Name="myCheckbox"
Grid.Row="2"
Grid.Column="0"
/>
<TextBlock
Name="checkboxTextBlock"
Width="350"
Height="30"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="3"
Text="Was The Agent Undercover?"
FontSize="25"
/>
<!-- Insert Radiobuttons on the next 3 rows-->
<RadioButton
Name="radioButton_CIA"
GroupName="Agency"
Grid.Row="3"
Grid.Column="3"
/>
<TextBlock Name="ciaTextBlock" Text="CIA" Grid.Column="3" Grid.Row="3" FontSize="25" Height="30" Width="160" Tap="ciaTextBlock_Tap" />
<RadioButton
Name="radioButton_FBI"
GroupName="Agency"
Grid.Row="4"
Grid.Column="3"
/>
<TextBlock Name="fbiTextBlock" Text="FBI" Grid.Row="4" Grid.Column="3" FontSize="25" Height="30" Width="160" Tap="fbiTextBlock_Tap" />
<RadioButton
Name="radioButton_MI6"
GroupName="Agency"
Grid.Row="5"
Grid.Column="3"
/>
<TextBlock Name="mi6TextBlock" Text="MI6" Grid.Row="5" Grid.Column="3" FontSize="25" Height="30" Width="160" Tap="mi6TextBlock_Tap" />
<Button Name="enterBotton" Content="Go" Grid.Row="7" Grid.Column="3" FontSize="25" Click="enterBotton_Click"/>
<ListBox Name="myList" Grid.Row="6" Grid.Column="0" >
<ListBoxItem Name="optionOne" Content="Find"/>
<ListBoxItem Name="optionTwo" Content="Store"/>
<ListBoxItem Name="optionThree" Content="Flip"/>
</ListBox>
</Grid>
</ScrollViewer>
</Grid>
<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->
</phone:PhoneApplicationPage>
Please Help Me!
Here is the Code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace WinHomeWork2
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void enterBotton_Click(object sender, RoutedEventArgs e)
{
var Agent = new Agent()
{
AgentName = AgentName.Text,
Password = Agent_Password.Password,
RecordTime = DateTime.Now,
Undercover = myCheckbox.IsChecked,
Agency = getAgency()
};
}
private string getAgency()
{
return (bool)radioButton_CIA.IsChecked? "CIA" : (bool)radioButton_FBI.IsChecked ? "FBI" : (bool)radioButton_MI6.IsChecked? "MI6" : null;
}
private void ciaTextBlock_Tap(object sender, GestureEventArgs e)
{
radioButton_CIA.IsChecked = true;
}
private void fbiTextBlock_Tap(object sender, GestureEventArgs e)
{
radioButton_FBI.IsChecked = true;
}
private void mi6TextBlock_Tap(object sender, GestureEventArgs e)
{
radioButton_MI6.IsChecked = true;
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
AgentName.Focus();
}
}
//Agent Class
public class Agent
{
public Agent() { }
public string AgentName { get; set; }
public string Password { get; set; }
public DateTime RecordTime { get; set; }
public bool? Undercover { get; set; }
public string Agency { get; set; }
}
}
Define Height of the Scrollviewer to make it fit in screen.
I guess the problem lies in these two statements. You have forgotten to change the Grid.Row value. Please make that change and try again
<ScrollViewer Grid.Row="1"
Name="mainScrollViewer"
Margin="0,175,0,0"
VerticalScrollBarVisibility="Visible" AllowDrop="False" ManipulationMode="Control">
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Margin="12,0,12,0">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With