Microsoft .NET/WPF
[WPF] 1. 화면 구성 - WrapPanel
전자기린
2019. 2. 27. 00:40
WrapPanel은 기본적으로 Control이 좌측상단에서부터 순차적으로 출력되며
Control들의 크기가 WrapPanel의 크기를 초과하게 되면 줄바꿈하게 됩니다.
WPF_Example_1_Layout_WrapPanel.zip
다운로드
<!--In Xaml-->
<WrapPanel>
<Button Content="1번 버튼"/>
<Button Content="2번 버튼"/>
<Button Content="3번 버튼"/>
<Button Content="4번 버튼"/>
</WrapPanel>
WrapPanel의 방향을 지정하지 않는다면 Top,Left에서 Bottom,Right 방향으로 Control을 배치합니다.
<!--In Xaml-->
<WrapPanel Orientation="Vertical"
FlowDirection="RightToLeft">
<Button Content="1번 버튼"/>
<Button Content="2번 버튼"/>
<Button Content="3번 버튼"/>
<Button Content="4번 버튼"/>
<Button Content="5번 버튼"/>
<Button Content="6번 버튼"/>
<Button Content="7번 버튼"/>
<Button Content="8번 버튼"/>
<Button Content="9번 버튼"/>
<Button Content="10번 버튼"/>
</WrapPanel>
WrapPanel에서는 Orientation 속성으로 Content의 가로, 세로 방향을 지정할 수 있으며,
가로방향일 경우 FlowDirection 속성으로 Content의 시작 방향을 지정할 수 있습니다.
또한
WrapPanel의 크기가 변경될 경우 자식 Content의 위치가 변경될 수 있습니다.