728x90
반응형
1) Column, Row 생성
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc ="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable ="d"
Title="Test" Height="300" Width="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</Window>
2) Width, Height 설정
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc ="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable ="d"
Title="Test" Height="300" Width="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="170"/>
<RowDefinition Height="30"/>
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</Window>
column,row
(0,0) (1,0) (2,0)
(0,1) (1,1) (2,1)
(0,2) (1,2) (2,2)
3) row와 column 안에 버튼과 textblock 넣기
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc ="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable ="d"
Title="Test" Height="300" Width="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="170"/>
<RowDefinition Height="30"/>
<RowDefinition />
</Grid.RowDefinitions>
<Button Name="btn1" Background="DarkBlue" Margin="40"></Button>
<Button Name="btnred" Grid.Column="1" Background="Aquamarine" Margin="40"></Button>
<TextBlock Grid.Row="1" FontSize="20"
HorizontalAlignment="Center">row 1 column 0</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1" FontSize="20"
HorizontalAlignment="Center">row 1 column 1</TextBlock>
</Grid>
</Window>
728x90
반응형
'c# > WPF' 카테고리의 다른 글
[WPF] 시작하기 (0) | 2022.03.22 |
---|