Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XAML:
- <Button Click="Button_Click_1" Margin="20">Vaihda sivua!</Button>
- <Button Click="Button_Click_2">RelativePanel!</Button>
- <Button Click="Button_Click_3">Grid!</Button>
- <Button Click="Button_Click_4">Tapahtumat!</Button>
- ---------------------
- <ComboBox Name="FoodList" SelectionChanged="ComboBox_SelectionChanged">
- <ComboBoxItem>Peruna</ComboBoxItem>
- <ComboBoxItem>Vichy</ComboBoxItem>
- <ComboBoxItem>Kahvi</ComboBoxItem>
- </ComboBox>
- <TextBlock Margin="30" FontSize="30" Name="FoodText"></TextBlock>
- -------------
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="300" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="200" />
- <RowDefinition />
- </Grid.RowDefinitions>
- <Rectangle Grid.Row="0" Grid.Column="0" Fill="DarkSalmon" />
- <Rectangle Grid.Row="0" Grid.Column="1" Fill="Green" />
- <Rectangle Grid.Row="1" Grid.Column="0" Fill="NavajoWhite" />
- <Rectangle Grid.Row="1" Grid.Column="1" Fill="Pink" />
- </Grid>
- ---------------
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="150"/>
- <ColumnDefinition Width="300" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="200" />
- <RowDefinition />
- </Grid.RowDefinitions>
- <Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Fill="DarkSalmon" />
- <Rectangle Grid.Row="1" Grid.Column="0" Fill="NavajoWhite" />
- <Rectangle Grid.Row="1" Grid.Column="1" Fill="Pink" />
- <Rectangle Grid.Row="1" Grid.Column="2" Fill="SandyBrown" />
- </Grid>
- --------------
- <StackPanel Margin="30">
- <Border>
- <TextBlock Name="MouseText"
- PointerEntered="MouseText_PointerEntered"
- PointerExited="MouseText_PointerExited"
- FontSize="60"
- Width="120">
- OFF
- </TextBlock>
- </Border>
- <TextBox TextChanged="TextBox_TextChanged"></TextBox>
- <Slider Name="NumberSlider" Minimum="1" Maximum="5" ValueChanged="NumberSlider_ValueChanged" />
- <TextBlock Name="SliderText"></TextBlock>
- <CheckBox Margin="10">Hyväksyn käyttöehdot</CheckBox>
- <RadioButton Margin="10" GroupName="confirmation">Kyllä</RadioButton>
- <RadioButton Margin="10" GroupName="confirmation">Ei</RadioButton>
- </StackPanel>
- C#:
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- // vaihdetaan sivua toiseen Pageen
- this.Frame.Navigate(typeof(SecondPage));
- }
- private void Button_Click_2(object sender, RoutedEventArgs e)
- {
- // vaihdetaan sivua toiseen Pageen
- this.Frame.Navigate(typeof(RelativeTesting));
- }
- private void Button_Click_3(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(GridTesting));
- }
- private void Button_Click_4(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(EventTesting));
- }
- -------------------
- // navigoidaan toiselle sivulle, esim Button Clickissä
- // jos sivu on SecondPage.xaml, silloin:
- this.Frame.Navigate(typeof(SecondPage));
- -----------------
- private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- // ensin haetaan aktiivinen ComboBoxItem...
- ComboBoxItem cb = FoodList.SelectedItem as ComboBoxItem;
- // ... ja sitten ComboBoxItemistä haetaan teksti
- string value = cb.Content.ToString();
- // asetetaan teksti TextBlockiin
- FoodText.Text = value;
- }
- ---------------------------
- private void MouseText_PointerEntered(object sender, PointerRoutedEventArgs e)
- {
- MouseText.Text = "ON!";
- }
- private void MouseText_PointerExited(object sender, PointerRoutedEventArgs e)
- {
- MouseText.Text = "OFF";
- }
- private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- Debug.WriteLine("Joku kirjoittaa nyt jotakin!");
- }
- private void NumberSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
- {
- Debug.WriteLine(NumberSlider.Value.ToString());
- if (SliderText != null)
- {
- SliderText.Text = NumberSlider.Value.ToString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement