■ DockLayoutManager 클래스에서 코드로 레이아웃 항목을 이동하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxd="http://schemas.devexpress.com/winfx/2008/xaml/docking" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" Width="800" Height="600" Title="코드로 레이아웃 항목 이동하기" FontFamily="나눔고딕코딩" FontSize="16"> <dxd:DockLayoutManager x:Name="dockLayoutManager"> <dxd:DockLayoutManager.LayoutRoot> <dxd:LayoutGroup x:Name="rootLayoutGroup" Orientation="Vertical"> <dxd:LayoutControlItem> <Button x:Name="moveButton" Content="Click to move item" Click="moveButton_Click" /> </dxd:LayoutControlItem> <dxd:LayoutControlItem x:Name="buttonLayoutControlItem"> <Button x:Name="button1" Content="Button 1" /> </dxd:LayoutControlItem> <dxd:LayoutControlItem x:Name="buttonEditLayoutControlItem"> <dxe:ButtonEdit x:Name="buttonEdit" Text="(555) 123 45 67 89" /> </dxd:LayoutControlItem> </dxd:LayoutGroup> </dxd:DockLayoutManager.LayoutRoot> </dxd:DockLayoutManager> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
using System.Windows; using DevExpress.Xpf.Layout.Core; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region Move 버튼 클릭시 처리하기 - moveButton_Click(sender, e) /// <summary> /// Move 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void moveButton_Click(object sender, RoutedEventArgs e) { this.dockLayoutManager.LayoutController.Move(this.buttonEditLayoutControlItem, this.buttonLayoutControlItem, MoveType.Left); } #endregion } } |