0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WPF覚え書き~コントロールのレイアウト~

Posted at

#はじめに
WPF学習中のため自分用に記載していきます。
間違い、不足などありましたらコメントをよろしくお願いします。

#HorizontalAlignment/VerticalAlignmentプロパティ
親要素に割り当てられた領域内で子要素をどのように配置するかを指定する。
●HorizontalAlignment:水平方向の配置方法を指定する
 Left(左寄せ)、Right(右寄せ)、Center(中央寄せ)、Stretch(親要素全体に広げる)

●VerticalAlignment:垂直方向の配置方法を指定する
 Top(上寄せ)、Bottom(下寄せ)、Center(中央寄せ)、Stretch(親要素全体に広げる)


~省略~
    <Grid ShowGridLines="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <Button Grid.Row="0" Grid.Column="0" Content="Default(Stretch)" />
        
        <Button Grid.Row="0" Grid.Column="1" Content="Left-Bottom" 
                HorizontalAlignment="Left" VerticalAlignment="Bottom" />
        
        <Button Grid.Row="0" Grid.Column="1" Content="Left-Top" 
                HorizontalAlignment="Left" VerticalAlignment="Top" />
        
        <Button Grid.Row="0" Grid.Column="1" Content="Right-Top" 
                HorizontalAlignment="Right" VerticalAlignment="Top" />
        
        <Button Grid.Row="0" Grid.Column="1" Content="Right-Bottom" 
                HorizontalAlignment="Right" VerticalAlignment="Bottom" />
        
        <Button Grid.Row="0" Grid.Column="1" Content="Center-Center" 
                HorizontalAlignment="Center" VerticalAlignment="Center" />
        
        <Button Grid.Row="0" Grid.Column="2" Content="Left-Center" 
                HorizontalAlignment="Left" VerticalAlignment="Center" />
        
        <Button Grid.Row="0" Grid.Column="2" Content="Right-Center" 
                HorizontalAlignment="Right" VerticalAlignment="Center" />
        
        <Button Grid.Row="0" Grid.Column="2" Content="Center-Top" 
                HorizontalAlignment="Center" VerticalAlignment="Top" />

        <Button Grid.Row="0" Grid.Column="2" Content="Center-Bottom" 
                HorizontalAlignment="Center" VerticalAlignment="Bottom" />
    </Grid>

<実行結果>

#HorizontalContentAlignment/VerticalContentAlignmentプロパティ
コントロールのコンテンツの配置をどのように設定するかを指定する。
●HorizontalContentAlignment:水平方向の配置方法を指定する
 Left(左寄せ)、Right(右寄せ)、Center(中央寄せ)、Stretch(親要素全体に広げる)

●VerticalContentAlignment:垂直方向の配置方法を指定する
 Top(上寄せ)、Bottom(下寄せ)、Center(中央寄せ)、Stretch(親要素全体に広げる)

#参照
かずきのBlog@hatena

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?