본문 바로가기

Programing (프로그래밍)/WPF & C# (C Sharp)

WPF & C# - Grid 열과 행으로 나누기 ( RowDefinitions / ColumnDefinitions )

728x90
반응형

 

 

 

 WPF & C# - Grid 열과 행으로 나누기 ( RowDefinitions / ColumnDefinitions

 )

 

 

 

 

 

Grid (열,행으로 나누기)

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="100"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="100"/>
        <ColumnDefinition Width="1*"/>
        <ColumnDefinition Width="100"/>
    </Grid.ColumnDefinitions>
    <Label Grid.Column="0" Grid.Row="0" Width="80" Content="0,0" FontSize="48" />
    <Label Grid.Column="1" Grid.Row="0" Width="80" Content="1,0" FontSize="48" />
    <Label Grid.Column="2" Grid.Row="0" Width="80" Content="2,0" FontSize="48" />
    <Label Grid.Column="0" Grid.Row="1" Width="80" Content="0,1" FontSize="48" />
    <Label Grid.Column="1" Grid.Row="1" Width="80" Content="1,1" FontSize="48" />
    <Label Grid.Column="2" Grid.Row="1" Width="80" Content="2,1" FontSize="48" />
    <Label Grid.Column="0" Grid.Row="2" Width="80" Content="0,2" FontSize="48" />
    <Label Grid.Column="1" Grid.Row="2" Width="80" Content="1,2" FontSize="48" />
    <Label Grid.Column="2" Grid.Row="2" Width="80" Content="2,2" FontSize="48" />
</Grid>

 

 

 

코드로 원하는 위치에 객체 삽입하기

MainWindow.xaml.cs

btn.Visibility = Visibility.Collapsed;
Grid.SetRow(btn, 0);
Grid.SetColumn(btn, 0);
btn.Visibility = Visibility.Visible;

 

 

참고

https://insurang.tistory.com/534

 

WPF & C# - 열행 맞추어 Grid 생성하기 ( makeGrid / ColumnDefinitions / RowDefinitions )

 WPF & C# - 열행 맞추어 Grid 생성하기 ( makeGrid / ColumnDefinitions / RowDefinitions ) MainWindow.xaml MainWindow.xaml.cs public MainWindow() { InitializeComponent(); Init(); } void Init() { // G..

insurang.tistory.com

 

 

 

 

728x90
반응형