tuomasvaltanen

Untitled

Feb 3rd, 2022 (edited)
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.64 KB | None | 0 0
  1. XAML:
  2.  
  3. <StackPanel Margin="20">
  4. <TextBlock FontSize="50">TOINEN SIVU</TextBlock>
  5. <CheckBox>Olen lukenut ja ymmärtänyt ehdot</CheckBox>
  6.  
  7. <TextBlock>Haluatko uutiskirjeen?</TextBlock>
  8. <RadioButton GroupName="NewsLetter">Kyllä</RadioButton>
  9. <RadioButton GroupName="NewsLetter">En</RadioButton>
  10.  
  11. <TextBlock>Valitse kieli:</TextBlock>
  12. <RadioButton GroupName="AppLanguage">Suomi</RadioButton>
  13. <RadioButton GroupName="AppLanguage">Svenska</RadioButton>
  14. <RadioButton GroupName="AppLanguage">English</RadioButton>
  15. </StackPanel>
  16.  
  17. -------------------
  18.  
  19. <Page
  20. x:Class="UWPCourseApp2022.SecondPage"
  21. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  22. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  23. xmlns:local="using:UWPCourseApp2022"
  24. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  25. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  26. mc:Ignorable="d"
  27. Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  28.  
  29. <StackPanel Margin="20">
  30. <TextBlock FontSize="50">TOINEN SIVU</TextBlock>
  31. <CheckBox>Olen lukenut ja ymmärtänyt ehdot</CheckBox>
  32.  
  33. <TextBlock>Haluatko uutiskirjeen?</TextBlock>
  34. <RadioButton GroupName="NewsLetter">Kyllä</RadioButton>
  35. <RadioButton GroupName="NewsLetter">En</RadioButton>
  36.  
  37. <TextBlock>Valitse kieli:</TextBlock>
  38. <RadioButton GroupName="AppLanguage">Suomi</RadioButton>
  39. <RadioButton GroupName="AppLanguage">Svenska</RadioButton>
  40. <RadioButton GroupName="AppLanguage">English</RadioButton>
  41.  
  42. <Rectangle HorizontalAlignment="Left"
  43. Width="200"
  44. Height="200"
  45. Fill="MediumOrchid">
  46.  
  47. </Rectangle>
  48.  
  49. <Image Source="Assets/citynight.jpg" Width="600" RenderTransformOrigin="0.5,0.5">
  50. <Image.RenderTransform>
  51. <CompositeTransform Rotation="217.228"/>
  52. </Image.RenderTransform>
  53. </Image>
  54.  
  55. </StackPanel>
  56. </Page>
  57. -----------------------------------------
  58.  
  59.  
  60. <ComboBox Margin="20" Width="200">
  61. <ComboBoxItem>Banaani</ComboBoxItem>
  62. <ComboBoxItem>Omena</ComboBoxItem>
  63. <ComboBoxItem>Mansikka</ComboBoxItem>
  64. <ComboBoxItem>Hunajavesimeloni</ComboBoxItem>
  65. </ComboBox>
  66.  
  67. <TextBlock Name="ComboTarget" Margin="20">Mitään ei ole vielä valittu</TextBlock>
  68.  
  69. ----------------------------
  70.  
  71. <Border Margin="20" Background="DarkBlue" Width="400" Height="200" HorizontalAlignment="Left">
  72. <TextBlock FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White">Tässä on jotain tekstiä</TextBlock>
  73. </Border>
  74.  
  75. ---------------------------
  76.  
  77. <RelativePanel Margin="10">
  78. <TextBlock Margin="20" Name="FirstText" FontWeight="Bold" FontSize="30">Ensimmäinen teksti</TextBlock>
  79.  
  80. <Button Margin="20" RelativePanel.RightOf="FirstText" Name="SecondButton">Testinappi</Button>
  81.  
  82. <Button Margin="20" RelativePanel.Below="SecondButton" RelativePanel.AlignLeftWith="SecondButton" Name="ThirdButton">Kolmas nappi</Button>
  83. </RelativePanel>
  84.  
  85. --------------------------------
  86. <Grid>
  87. <Grid.ColumnDefinitions>
  88. <ColumnDefinition />
  89. <ColumnDefinition />
  90. </Grid.ColumnDefinitions>
  91.  
  92. <Grid.RowDefinitions>
  93. <RowDefinition />
  94. <RowDefinition />
  95. </Grid.RowDefinitions>
  96.  
  97. <Rectangle Grid.Row="0" Grid.Column="0" Fill="DarkMagenta"></Rectangle>
  98. <Rectangle Grid.Row="0" Grid.Column="1" Fill="LawnGreen"></Rectangle>
  99. <Rectangle Grid.Row="1" Grid.Column="0" Fill="LightPink"></Rectangle>
  100. <Rectangle Grid.Row="1" Grid.Column="1" Fill="Teal"></Rectangle>
  101. </Grid>
  102. -------------------------------
  103. <Grid>
  104. <Grid.ColumnDefinitions>
  105. <ColumnDefinition Width="200" />
  106. <ColumnDefinition Width="300"/>
  107. <ColumnDefinition Width="*" />
  108. </Grid.ColumnDefinitions>
  109.  
  110. <Grid.RowDefinitions>
  111. <RowDefinition Height="150"/>
  112. <RowDefinition />
  113. </Grid.RowDefinitions>
  114.  
  115. <Rectangle Grid.Row="0" Grid.Column="0" Fill="DarkMagenta"></Rectangle>
  116. <Rectangle Grid.Row="0" Grid.Column="1" Fill="LawnGreen"></Rectangle>
  117. <Rectangle Grid.Row="0" Grid.Column="2" Fill="DarkRed"></Rectangle>
  118. <Rectangle Grid.Row="1" Grid.Column="0" Fill="LightPink"></Rectangle>
  119. <Rectangle Grid.Row="1" Grid.Column="1" Fill="Teal"></Rectangle>
  120. <Rectangle Grid.Row="1" Grid.Column="2" Fill="MediumSpringGreen"></Rectangle>
  121. </Grid>
  122. ----------------------------
  123. <Grid>
  124. <Grid.ColumnDefinitions>
  125. <ColumnDefinition Width="*" />
  126. <ColumnDefinition Width="240"/>
  127.  
  128. </Grid.ColumnDefinitions>
  129.  
  130. <Grid.RowDefinitions>
  131. <RowDefinition Height="200"/>
  132. <RowDefinition />
  133. </Grid.RowDefinitions>
  134.  
  135. <!-- Ensimmäinen rivi + sarake, yhdistää kaksi saraketta yhdeksi (column span) -->
  136. <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Background="BurlyWood">
  137. <TextBlock Padding="30" FontSize="60" FontWeight="Bold">YRITYS OY AB</TextBlock>
  138. </StackPanel>
  139.  
  140. <!-- varsinainen sisältö -->
  141. <RelativePanel Grid.Row="1" Grid.Column="0" Background="Gainsboro">
  142. <Button Name="FirstButton" Margin="30">Tee uusi lomake</Button>
  143.  
  144. <Button RelativePanel.Below="FirstButton" Margin="30">Selaa vanhoja lomakkeita</Button>
  145. </RelativePanel>
  146.  
  147. <!-- oikeanpuoleinen apuvalikko -->
  148. <StackPanel Grid.Row="1" Grid.Column="1" Background="LightSteelBlue">
  149. <ComboBox Margin="30" HorizontalAlignment="Center">
  150. <ComboBoxItem>Rovaniemi</ComboBoxItem>
  151. <ComboBoxItem>Tornio</ComboBoxItem>
  152. <ComboBoxItem>Oulu</ComboBoxItem>
  153. </ComboBox>
  154. </StackPanel>
  155.  
  156. </Grid>
  157. -----------------------------------------
  158.  
  159. <Border Margin="20"
  160. Width="200" Height="200"
  161. Background="MediumPurple"
  162. PointerEntered="Border_PointerEntered"
  163. PointerExited="Border_PointerExited">
  164. <TextBlock FontSize="20" HorizontalAlignment="Center" Name="MouseText">
  165. Laita hiiri päälle
  166. </TextBlock>
  167. </Border>
  168.  
  169. ------------------------------
  170. C#:
  171.  
  172. // navigointi toiseen Pageen, esim. MainPagessa
  173. private void Button_Click_1(object sender, RoutedEventArgs e)
  174. {
  175. this.Frame.Navigate(typeof(SecondPage));
  176. }
  177.  
  178. -----------------
  179.  
  180.  
  181. private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  182. {
  183. // muutetaan sender ComboBoxiksi, eli mistä comboboxista muutospyyntö tuli
  184. ComboBox cb = sender as ComboBox;
  185.  
  186. // haetaan valittu asia comboboxista ja muutetaan se comboboxitemiksi
  187. ComboBoxItem item = cb.SelectedItem as ComboBoxItem;
  188.  
  189. // haetaan valinnan teksti comboboxitemiksi
  190. String txt = item.Content as String;
  191.  
  192. ComboTarget.Text = txt;
  193. }
  194.  
  195. -----------------------
  196.  
  197.  
  198.  
  199. private void Border_PointerEntered(object sender, PointerRoutedEventArgs e)
  200. {
  201. MouseText.Text = "Hiiri on päällä!";
  202. }
  203.  
  204. private void Border_PointerExited(object sender, PointerRoutedEventArgs e)
  205. {
  206. MouseText.Text = "Hiiri poistui...";
  207. }
Add Comment
Please, Sign In to add comment