반응형



<Window x:Class="practice1.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:practice1"

        mc:Ignorable="d"

        Title="MainWindow" Height="450" Width="800">

    <Grid>

        <StackPanel>

            <Button Content="Left Button"

                    HorizontalAlignment="Left"/>

            <Button Content="Right Button"

                    HorizontalAlignment="Right"/>

            <Button Content="Center Button"

                    HorizontalAlignment="Center"/>

            <Button Content="Stretch BUtton"

                    HorizontalAlignment="Stretch"/>

        </StackPanel>

    </Grid>

</Window>



Button을 생성하고, 각 내용에 맞는 Content 설정


HorizontalAlignment를 Left로 하면 왼쪽, Right로 하면 오른쪽, Center로 하면 중앙에 배치

Stretch로 하면 변화가 없는데, Button의 Default 값이 Strecth라는 것을 알 수 있음.








<Window x:Class="practice1.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:practice1"

        mc:Ignorable="d"

        Title="MainWindow" Height="450" Width="800">

    <Grid>

        <StackPanel>

            <Button Content="Left Button"

                    HorizontalContentAlignment="Left"/>

            <Button Content="Right Button"

                    HorizontalContentAlignment="Right"/>

            <Button Content="Center Button"

                    HorizontalContentAlignment="Center"/>

            <Button Content="Stretch Button"

                    HorizontalContentAlignment="Stretch"/>

        </StackPanel>

    </Grid>

</Window>



위의 코드에서 HorizontalAlignment를 HorizontalContentAlignment로 변경을 하게 되면, 버튼안의 Content가 정렬이 된다.


반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기