Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. **XAML**
  2.  
  3. <Grid x:Name="LayoutRoot" Background="Transparent">
  4. <Grid.RowDefinitions>
  5. <RowDefinition Height="Auto"/>
  6. <RowDefinition Height="*"/>
  7. </Grid.RowDefinitions>
  8.  
  9. <!--TitlePanel contains the name of the application and page title-->
  10. <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,0,0,0">
  11. <TextBlock x:Name="PageTitle" Text="sign in" Margin="0,0,0,0" Height="125" Style="{StaticResource PhoneTextTitle1Style}" Tap="PageTitle_Tap"/>
  12. </StackPanel>
  13.  
  14. <ScrollViewer Grid.Row="1" x:Name="Scroller" VerticalAlignment="Top">
  15. <Grid x:Name="ContentPanel" Grid.Row="1">
  16. <Grid.RowDefinitions>
  17. <RowDefinition Height="Auto"/>
  18. <RowDefinition Height="Auto"/>
  19. <RowDefinition Height="Auto"/>
  20. <RowDefinition Height="Auto"/>
  21. <RowDefinition Height="Auto"/>
  22. <RowDefinition Height="Auto"/>
  23. <RowDefinition Height="Auto"/>
  24. <RowDefinition Height="Auto"/>
  25. </Grid.RowDefinitions>
  26.  
  27. <TextBlock Grid.Row="0" Name="EnterUserIdTitle" Margin="24,0,14,6" FontSize="26" Text="Username"/>
  28. <TextBox Grid.Row="1" Name="EnterUserIdInput" Margin="12,0,24,6" Text="" GotFocus="EnterUserIdInput_GotFocus" LostFocus="UserIdLostFocus" />
  29.  
  30. <TextBlock Grid.Row="2" Name="EnterPwdTitle" Margin="24,0,14,6" FontSize="26" Text="Password"/>
  31. <PasswordBox Grid.Row="3" Name="EnterPwdInput" Margin="12,0,24,6" GotFocus="EnterPwdInput_GotFocus" LostFocus="EnterPwdInput_LostFocus"/>
  32.  
  33. <TextBlock Grid.Row="4" Name="ServerUrlTitle" Margin="24,10,24,6" FontSize="26" Text="namespace"/>
  34. <TextBox Grid.Row="5" Name="ServerUrlInput" Margin="12,0,24,6" Text="" TextWrapping="Wrap" GotFocus="ServerUrlInput_GotFocus" LostFocus="ServerUrlInput_LostFocus"/>
  35. <Grid Grid.Row="6" Name="DebugEndPointGrid">
  36. <Grid.RowDefinitions>
  37. <RowDefinition Height="Auto"/>
  38. <RowDefinition Height="Auto"/>
  39. </Grid.RowDefinitions>
  40.  
  41. <TextBlock Grid.Row="0" Name="DebugEndpointTitle" Margin="24,10,24,6" FontSize="26" Text="End Point"/>
  42. <TextBox Grid.Row="1" Name="DebugEndpoint" Height="72" Margin="12,0,24,6" GotFocus="DebugEndpoint_GotFocus" LostFocus="DebugEndpoint_LostFocus" />
  43. </Grid>
  44. <CheckBox Grid.Row="7" Name="RemeberCheckbox" Margin="12,0,24,6" Content="Remember Me" IsChecked="True"/>
  45.  
  46. </Grid>
  47. </ScrollViewer>
  48. </Grid>
  49.  
  50.  
  51. ----------
  52. **C#**
  53.  
  54. public partial class MainPage : PhoneApplicationPage
  55. {
  56. public const string SettingsPageUri = @"/SettingsPage.xaml";
  57.  
  58. private double DefaultScrollerHeight;
  59. private int SIPVisibleScrollerHeight = 250;
  60. private int UserIDOffset = 0;
  61. private int PasswordOffset = 110;
  62. private int ServiceUrlOffset = 250;
  63. private int DebugOffset = 300;
  64. // Constructor
  65. public MainPage()
  66. {
  67. InitializeComponent();
  68.  
  69. this.Loaded += new RoutedEventHandler(SettingsPage_Loaded);
  70. }
  71.  
  72. private void SettingsPage_Loaded(object sender, RoutedEventArgs e)
  73. {
  74. // Code to avoid screen from pushing upward on launch of SIP and provides options to resize the scroller and remove elastic effect from forms by enabling scrollers when SIP is activated.
  75. // Header also does not push up when textbox gets focus.
  76. //(App.Current as App).RootFrame.RenderTransform = new CompositeTransform();
  77.  
  78. DefaultScrollerHeight = this.Scroller.Height;
  79.  
  80. EnterUserIdInput.Tag = false;
  81. EnterPwdInput.Tag = false;
  82. ServerUrlInput.Tag = false;
  83. DebugEndpoint.Tag = false;
  84. }
  85.  
  86. private void EnterUserIdInput_GotFocus(object sender, RoutedEventArgs e)
  87. {
  88. EnterUserIdInput.Tag = true;
  89. if (this.Scroller.Height != SIPVisibleScrollerHeight)
  90. {
  91. this.Scroller.Height = SIPVisibleScrollerHeight;
  92. this.Scroller.UpdateLayout();
  93. this.Scroller.ScrollToVerticalOffset(UserIDOffset);
  94. }
  95. }
  96.  
  97. private void UserIdLostFocus(object sender, RoutedEventArgs e)
  98. {
  99. EnterUserIdInput.Tag = false;
  100. }
  101.  
  102. private void EnterPwdInput_GotFocus(object sender, RoutedEventArgs e)
  103. {
  104. EnterPwdInput.Tag = true;
  105.  
  106. if (this.Scroller.Height != SIPVisibleScrollerHeight)
  107. {
  108. this.Scroller.Height = SIPVisibleScrollerHeight;
  109. this.Scroller.UpdateLayout();
  110. this.Scroller.ScrollToVerticalOffset(PasswordOffset);
  111. }
  112. }
  113.  
  114. private void EnterPwdInput_LostFocus(object sender, RoutedEventArgs e)
  115. {
  116. EnterPwdInput.Tag = false;
  117. }
  118.  
  119. private void ServerUrlInput_GotFocus(object sender, RoutedEventArgs e)
  120. {
  121. ServerUrlInput.Tag = true;
  122.  
  123. if (this.Scroller.Height != SIPVisibleScrollerHeight)
  124. {
  125. this.Scroller.Height = SIPVisibleScrollerHeight;
  126. this.Scroller.UpdateLayout();
  127. this.Scroller.ScrollToVerticalOffset(ServiceUrlOffset);
  128. }
  129. }
  130.  
  131. private void ServerUrlInput_LostFocus(object sender, RoutedEventArgs e)
  132. {
  133. ServerUrlInput.Tag = false;
  134. }
  135.  
  136. private void DebugEndpoint_GotFocus(object sender, RoutedEventArgs e)
  137. {
  138. DebugEndpoint.Tag = true;
  139.  
  140. if (this.Scroller.Height != SIPVisibleScrollerHeight)
  141. {
  142. this.Scroller.Height = SIPVisibleScrollerHeight;
  143. this.Scroller.UpdateLayout();
  144. this.Scroller.ScrollToVerticalOffset(DebugOffset);
  145. }
  146. }
  147.  
  148. private void DebugEndpoint_LostFocus(object sender, RoutedEventArgs e)
  149. {
  150. DebugEndpoint.Tag = false;
  151. }
  152.  
  153. private void SettingsPage_GotFocus(object sender, RoutedEventArgs e)
  154. {
  155. if (!((bool)EnterUserIdInput.Tag) && !((bool)EnterPwdInput.Tag) && !((bool)ServerUrlInput.Tag) && !((bool)DebugEndpoint.Tag))
  156. {
  157. this.Scroller.Height = DefaultScrollerHeight;
  158. this.Scroller.UpdateLayout();
  159. }
  160. }
  161. private void PageTitle_Tap(object sender, System.Windows.Input.GestureEventArgs e)
  162. {
  163. this.Scroller.Height = DefaultScrollerHeight;
  164. this.Scroller.UpdateLayout();
  165. }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement