레이아웃 확장 - DockPanel
.NET프로그래밍/Silverlight 3.0 2009. 11. 25. 09:31 |
- DockPanel : 좌상우하 영역에 도킹할 수 있는 패널
-> "DockPanel"은 "WrapPanel"과 달리 "도구상자"에서 "항목추가"를 안해도 도구상자의 "All Silverlight Controls"탭 안의 항목에 포함되어 있다.
-------------------------------------------------------------------------------------
[MainPage.xaml]
<UserControl
xmlns:redpus="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
x:Class="RiaDockPanel.MainPage"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<redpus:DockPanel LastChildFill="False">
<Button Content="#1"></Button>
<Button Content="#2" redpus:DockPanel.Dock="Top"></Button>
<Button Content="#3" redpus:DockPanel.Dock="Right"></Button>
<Button Content="#4" redpus:DockPanel.Dock="Bottom"></Button>
</redpus:DockPanel>
</Grid>
</UserControl>
-------------------------------------------------------------------------------------
[FrmDockPanel.xaml]
<UserControl
xmlns:redplus="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" x:Class="RiaDockPanel.FrmDockPanel"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<redplus:DockPanel LastChildFill="False">
<Button redplus:DockPanel.Dock="Left" Background="LightBlue" Content="#1" />
<Button redplus:DockPanel.Dock="Top" Background="LightCoral" Content="#2" />
<Button redplus:DockPanel.Dock="Right" Background="LightGreen" Content="#3" />
<Button redplus:DockPanel.Dock="Bottom" Background="LightYellow" Content="#4" />
<Button redplus:DockPanel.Dock="Left" Background="LightGreen" Content="#5" />
<Button redplus:DockPanel.Dock="Top" Background="LightYellow" Content="#6" />
<Button redplus:DockPanel.Dock="Right" Background="LightBlue" Content="#7" />
<Button redplus:DockPanel.Dock="Bottom" Background="LightCoral" Content="#8" />
<Button redplus:DockPanel.Dock="Left" Background="LightGray" Content="#9" />
<Button redplus:DockPanel.Dock="Top" Background="LightCoral" Content="#10" />
<Button redplus:DockPanel.Dock="Right" Background="LightGreen" Content="#11" />
<Button redplus:DockPanel.Dock="Bottom" Background="LightBlue" Content="#12" />
<Button redplus:DockPanel.Dock="Left" Background="LightCoral" Content="#13" />
<Button redplus:DockPanel.Dock="Top" Background="LightGoldenrodYellow" Content="#14" />
<Button redplus:DockPanel.Dock="Right" Background="LightYellow" Content="#15" />
<Button redplus:DockPanel.Dock="Bottom" Background="LightGreen" Content="#16" />
<Button redplus:DockPanel.Dock="Left" Background="LightYellow" Content="#17" />
<Button redplus:DockPanel.Dock="Top" Background="LightCoral" Content="#18" />
<Button redplus:DockPanel.Dock="Right" Background="LightBlue" Content="#19" />
<Button redplus:DockPanel.Dock="Bottom" Background="LightGreen" Content="#20" />
<Button redplus:DockPanel.Dock="Left" Background="LightBlue" Content="#21" />
<Button redplus:DockPanel.Dock="Top" Background="LightGreen" Content="#22" />
<Button redplus:DockPanel.Dock="Right" Background="LightCoral" Content="#23" />
<Button redplus:DockPanel.Dock="Bottom" Background="LightYellow" Content="#24" />
</redplus:DockPanel>
</Grid>
</UserControl>
-------------------------------------------------------------------------------------
[App.xaml.cs]
namespace RiaDockPanel
{
public partial class App : Application
{
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
// 시작 XAML 설정
this.RootVisual = new FrmDockPanel();
}
private void Application_Exit(object sender, EventArgs e)
{
}
-------------------------------------------------------------------------------------
[실행결과]
'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글
도형(Shape) - <Ellipse> : 타원 (0) | 2009.11.25 |
---|---|
도형(Shape) - <Rectangle /> : 사각형 (0) | 2009.11.25 |
레이아웃 확장 - WrapPanel (0) | 2009.11.25 |
레이아웃 - <Border />클래스 (레이아웃에 테두리 주기) (0) | 2009.11.24 |
Padding(패내마외)과 Margin(좌상우하) (0) | 2009.11.24 |