Layout
WPFÀÇ ·¹À̾ƿôÀº ÆгÎÀÇ ÀÚ½Ä Ä÷º¼Ç¿¡ Æ÷ÇԵǴ ¿ä¼Òµé(´ÜÃß, ÅؽºÆ® »óÀÚµî)À» ¾î¶»°Ô Á¤·ÄÇÏ°í ¹èÄ¡ ÇÒ°ÍÀÎÁö ÁöÁ¤ÇÑ´Ù. ·¹À̾ƿô¿¡ µé¾î°¡±â Àü¿¡ WPF¿¡¼ ¸®¼Ò½º¸¦ Ãß°¡ÇÏ´Â ¹æ¹ý¿¡ ´ëÇØ ¾Ë¾Æº»´Ù. ¸®¼Ò½º Ãß°¡¼Ö·ç¼Ç Ž»ö±â¿¡¼ Resources.resx ´õºí Ŭ¸¯ ¸®¼Ò½º Ãß°¡ ´Ù¿î ¹öÆ° Ŭ¸¯ ±âÁ¸ ÆÄÀÏ Ãß°¡ ÆÄÀÏÀ» Ãß°¡Çϸé Resources Æú´õ°¡ »ý±â°í Ãß°¡ µÈ ÆÄÀÏÀÌ Resources Æú´õ·Î º¹»ç µÈ´Ù. ÆÄÀÏÀ» Ãß°¡ ÇÒ ¶§ °°Àº ÇÁ·ÎÁ§Æ® Æú´õ¿¡ ÀÖÀ¸¸é Resources Æú´õ°¡ »ý¼ºµÇÁö ¾Ê°í ÆÄÀϵµ º¹»çÇÏÁö ¾Ê´Â´Ù. ´ÙÀ½Àº ¼Ö·ç¼Ç Ž»ö±â¿¡ ¸®¼Ò½º°¡ Ãß°¡µÈ ȸéÀÌ´Ù. Image ÄÁÆ®·Ñ Ãß°¡ ¸®¼Ò½º¿¡ Ãß°¡ÇÏÁö ¾Ê°í ¹Ù·Î Ãß°¡Çصµ »ó°ü¾ø´Ù. ÀÌÁ¦ ·¹À̾ƿô¿¡ ´ëÇؼ ¾Ë¾Æº¸ÀÚ. Canvas :»ó´ëÀûÀÎ ÁÂÇ¥¸¦ »ç¿ëÇÏ¿© ÀÚ½Ä ¿ä¼Ò¸¦ ¸í½ÃÀûÀ¸·Î ¹èÄ¡ ÇÒ ¼ö ÀÖ´Ù.
Canvas
<Window x:Class="Layout.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Canvas Name="canvas1"> <Image Canvas.Left="29" Canvas.Top="52" Height="228" Name="image1" Stretch="Fill" Width="342" Source="file:///D:/workWPF/Layout/Resources/Tang_wei.jpg" /> <Button Canvas.Left="29" Canvas.Top="17" Content="Button1" Height="23" Name="button1" Width="149" /> <Button Canvas.Left="184" Canvas.Top="17" Content="Button2" Height="23" Name="button2" Width="187" /> </Canvas> </Window> StackPanel :¼öÆò ¶Ç´Â ¼¼·Î·Î ¿ä¼ÒµéÀ» ¹èÄ¡ÇÑ´Ù. ½ºÆÑÀÇ ¹æÇâÀÌ ¼öÆòÀ̸é Orientation="Horizontal" ¼öÁ÷À̸é Orientation="Vertical"·Î ¼³Á¤ÇÑ´Ù. StackPanel
<Window x:Class="Layout.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <StackPanel Name="StackPanel" Orientation="Vertical"> <Image Canvas.Left="29" Canvas.Top="52" Height="228" Name="image1" Stretch="Fill" Width="342" Source="file:///D:/workWPF/Layout/Resources/Tang_wei.jpg" /> <Button Canvas.Left="29" Canvas.Top="17" Content="Button1" Height="23" Name="button1" Width="149" /> <Button Canvas.Left="184" Canvas.Top="17" Content="Button2" Height="23" Name="button2" Width="187" /> </StackPanel> </Window>
WrapPanel :ÀڽĿä¼ÒµéÀÇ Å©±âº¸´Ù WrapPanel »çÀÌÁî°¡ ÀÛÀ¸¸é ¼öÆòÀ¸·Î ¹èÄ¡, ÀÚ½ÄÀÇ ¿ä¼Òº¸´Ù WrapPanel »çÀÌÁî°¡ ÀÛÀ¸¸é ½ºÅÃÆгÎó·³ ¾Æ·¡·Î ³»·Á°£´Ù. WrapPanel
<Window x:Class="Layout.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <WrapPanel Name="WrapPanel"> <Image Canvas.Left="29" Canvas.Top="52" Height="228" Name="image1" Stretch="Fill" Width="342" Source="file:///D:/workWPF/Layout/Resources/Tang_wei.jpg" /> <Button Canvas.Left="29" Canvas.Top="17" Content="Button1" Height="23" Name="button1" Width="149" /> <Button Canvas.Left="184" Canvas.Top="17" Content="Button2" Height="23" Name="button2" Width="187" /> </WrapPanel> </Window>
DockPanel :ÀÚ½Ä ¿ä¼Ò¸¦ Top, Left, Bottom, Right ¿É¼Ç¿¡ µû¶ó ¹èÄ¡¸¦ ¹Ù²Ü¼ö ÀÖ´Ù.
DockPanel
<Window x:Class="Layout.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <DockPanel Name="DockPanel" LastChildFill="True"> <Button Content="Button1" Height="23" Name="button1" Width="75" IsCancel="True" DockPanel.Dock="Top" /> <Button Content="Button2" Height="23" Name="button2" Width="75" /> <Button Content="Button3" Height="23" Name="button3" Width="75" DockPanel.Dock="Bottom" /> <Button Content="Button4" Height="30" Name="button4" Width="90" DockPanel.Dock="Right" /> <Button Content="Button5" Height="23" Name="button5" Width="75" DockPanel.Dock="Top" /> </DockPanel > </Window> Button5´Â TopÀε¥µµ Áß°£¿¡ À§Ä¡ÇÏ°í ÀÖ´Ù. ¸¶Áö¸· ÀÚ½Ä ¿ä¼Ò´Â ÇÒ´çµÇÁö ¾Ê´Â ¿µ¿ªÀ» ä¿ï·Á°í Çϱ⠶§¹®¿¡ ¿øÇÏ´Â À§Ä¡·Î ¹èÄ¡°¡ ¾ÈµÈ´Ù. LastChildFillÀ» ¿É¼ÇÀ» ²ô¸é ³²Àº ¿ª·ÂÀ» ä¿ìÁö ¾Ê±â ¶§¹®¿¡ ¿øÇÏ´Â À§Ä¡·Î À̵¿ ½Ãų¼ö ÀÖ´Ù.
Grid :ColumnDefinition¿Í RowDefinition¸¦ »ç¿ëÇÏ¿© Grid¸¦ ³ª´ ¼ö ÀÖ´Ù. ¸®¼Ò½º ¿¡µðÅÍ¿¡¼ ColumnDefinition¿Í RowDefinition¸¦ Á¤ÀÇÇÑ ¸ð½ÀÀÌ´Ù. Grid
<Window x:Class="Layout.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid Name="grid1" Width="400"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Button Content="Button1" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1"/> <Button Content="Button2" Grid.Column="2" Grid.RowSpan="3"/> </Grid> </Window>
|