<Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="300" Width="300"> <Grid> <Grid Margin="21,23,25,0" Name="Grid1" Height="100" VerticalAlignment="Top" Background="AliceBlue"> <TextBox Margin="15,16,15,0" Name="TextBox1" Height="24" VerticalAlignment="Top" /> <Button Height="23" HorizontalAlignment="Right" Margin="0,0,15,14" Name="Button1" VerticalAlignment="Bottom" Width="75">日時</Button> </Grid> <Slider Height="22" Margin="12,0,12,12" Name="Slider1" VerticalAlignment="Bottom" Maximum="360" /> <TextBlock Height="48" HorizontalAlignment="Left" Margin="44,160,0,0" Name="TextBlock1" Text="TextBlock" VerticalAlignment="Top" Width="180" /> </Grid> </Window>
<Window>階層1 <Grid>階層2 <Grid>階層3-1 <TextBox/>階層4-1 <Button><Button/>階層4-1 </Grid> <Slider/>階層3-2 <TextBlock/>階層3-2 </Grid> </Window>(1)XAMLを理解するには、まずXAMLの階層構造を理解する必要があります。(サンプルは上記のようになります。)
Class MainWindow Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click ' テキスト ボックスに現在日時を表示 Me.TextBox1.Text = DateTime.Now.ToString() Me.TextBlock1.Text = "8889" & vbTab & "2222" & vbCrLf & "555" End Sub Private Sub Slider1_ValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.RoutedPropertyChangedEventArgs(Of System.Double)) Handles Slider1.ValueChanged ' Grid コントロールを回転] Dim rt As New RotateTransform() rt.CenterX = 140 ' (140, 50) の位E置を中心に回転 rt.CenterY = 50 rt.Angle = e.NewValue ' スライダーの値の角度に回転 Me.Grid1.RenderTransform = rt End Sub End Class