첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.02MB

▶ MainPage.xaml

<Page x:Class="TestProject.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <Border
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            BorderThickness="1"
            BorderBrush="{ThemeResource TextControlBorderBrush}">
            <muxc:TreeView Name="treeView"
                Width="400"
                Height="400"
                AllowDrop="True"
                CanDragItems="True"
                ItemInvoked="treeView_ItemInvoked" />
        </Border>
    </Grid>
</Page>

 

728x90

 

▶ MainPage.xaml.cs

using Windows.Foundation;
using Windows.Graphics.Display;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

using muxc = Microsoft.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 메인 페이지
    /// </summary>
    public sealed partial class MainPage : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainPage()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainPage()
        {
            InitializeComponent();

            #region 윈도우 크기를 설정한다.

            double width  = 800d;
            double height = 600d;

            double dpi = (double)DisplayInformation.GetForCurrentView().LogicalDpi;

            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            Size windowSize = new Size(width * 96d / dpi, height * 96d / dpi);

            ApplicationView.PreferredLaunchViewSize = windowSize;

            Window.Current.Activate();

            ApplicationView.GetForCurrentView().TryResizeView(windowSize);

            #endregion
            #region 윈도우 제목을 설정한다.

            ApplicationView.GetForCurrentView().Title = "TreeView 엘리먼트 : AllowDrop/CanDragItems 속성을 사용해 드래그 & 드롭 지원하기";

            #endregion

            muxc.TreeViewNode workFolder = new muxc.TreeViewNode() { Content = "Work Documents" };

            workFolder.IsExpanded = true;

            workFolder.Children.Add(new muxc.TreeViewNode() { Content = "XYZ Functional Spec"          });
            workFolder.Children.Add(new muxc.TreeViewNode() { Content = "Feature Schedule"             });
            workFolder.Children.Add(new muxc.TreeViewNode() { Content = "Overall Project Plan"         });
            workFolder.Children.Add(new muxc.TreeViewNode() { Content = "Feature Resources Allocation" });

            muxc.TreeViewNode remodelFolder = new muxc.TreeViewNode() { Content = "Home Remodel" };

            remodelFolder.IsExpanded = true;

            remodelFolder.Children.Add(new muxc.TreeViewNode() { Content = "Contractor Contact Info" });
            remodelFolder.Children.Add(new muxc.TreeViewNode() { Content = "Paint Color Scheme"      });
            remodelFolder.Children.Add(new muxc.TreeViewNode() { Content = "Flooring woodgrain type" });
            remodelFolder.Children.Add(new muxc.TreeViewNode() { Content = "Kitchen cabinet style"   });

            muxc.TreeViewNode personalFolder = new muxc.TreeViewNode() { Content = "Personal Documents" };

            personalFolder.IsExpanded = true;

            personalFolder.Children.Add(remodelFolder);

            this.treeView.RootNodes.Add(workFolder);
            this.treeView.RootNodes.Add(personalFolder);
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 트리 뷰 항목 호출시 처리하기 - treeView_ItemInvoked(sender, e)

        /// <summary>
        /// 트리 뷰 항목 호출시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void treeView_ItemInvoked(muxc.TreeView sender, muxc.TreeViewItemInvokedEventArgs e)
        {
            return;
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요