첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
728x170

TestProject.zip
0.03MB

▶ SampleCompactSizingPage.xaml

<Page x:Class="TestProject.SampleCompactSizingPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Page.Resources>
        <ResourceDictionary Source="ms-appx:///Microsoft.UI.Xaml/DensityStyles/Compact.xaml" />
    </Page.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel Spacing="4">
            <TextBlock Name="HeaderBlock"
                FontSize="18"
                Text="컴팩트 크기" />
            <TextBox Name="firstNameTextBox"
                Header="이름 :" />
            <TextBox Name="lastNameTextBox"
                Header="성 :" />
            <PasswordBox Name="passwordPasswordBox"
                Header="패스워드 :" />
            <PasswordBox Name="confirmPasswordPasswordBox"
                Header="패스워드 확인 :" />
            <DatePicker Name="chosenDatePicker"
                Header="날짜 선택" />
        </StackPanel>
    </Grid>
</Page>

 

▶ SampleCompactSizingPage.xaml.cs

using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 샘플 컴팩트 크기 페이지
    /// </summary>
    public sealed partial class SampleCompactSizingPage : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 이름 - FirstName

        /// <summary>
        /// 이름
        /// </summary>
        public TextBox FirstName => this.firstNameTextBox;

        #endregion
        #region 성 - LastName

        /// <summary>
        /// 성
        /// </summary>
        public TextBox LastName => this.lastNameTextBox;

        #endregion
        #region 패스워드 - Password

        /// <summary>
        /// 패스워드
        /// </summary>
        public PasswordBox Password => this.passwordPasswordBox;

        #endregion
        #region 패스워드 확인 - ConfirmPassword

        /// <summary>
        /// 패스워드 확인
        /// </summary>
        public PasswordBox ConfirmPassword => this.confirmPasswordPasswordBox;

        #endregion
        #region 선택 날짜 - ChosenDate

        /// <summary>
        /// 선택 날짜
        /// </summary>
        public DatePicker ChosenDate => this.chosenDatePicker;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SampleCompactSizingPage()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 상태 복사하기 - CopyState(page)

        /// <summary>
        /// 상태 복사하기
        /// </summary>
        /// <param name="page">샘플 표준 크기 페이지</param>
        public void CopyState(SampleStandardSizingPage page)
        {
            FirstName.Text           = page.FirstName.Text;
            LastName.Text            = page.LastName.Text;
            Password.Password        = page.Password.Password;
            ConfirmPassword.Password = page.ConfirmPassword.Password;
            ChosenDate.Date          = page.ChosenDate.Date;
        }

        #endregion
    }
}

 

▶ SampleStandardSizingPage.xaml

<Page x:Class="TestProject.SampleStandardSizingPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel Spacing="4">
            <TextBlock Name="HeaderBlock"
                FontSize="18"
                Text="표준 크기" />
            <TextBox Name="firstNameTextBox"
                Header="이름 :" />
            <TextBox Name="lastNameTextBox"
                Header="성 :" />
            <PasswordBox Name="passwordPasswordBox"
                Header="패스워드 :" />
            <PasswordBox Name="confirmPasswordPasswordBox"
                Header="패스워드 확인 :" />
            <DatePicker Name="chosenDatePicker"
                Header="날짜 선택" />
        </StackPanel>
    </Grid>
</Page>

 

▶ SampleStandardSizingPage.xaml.cs

using Windows.UI.Xaml.Controls;

namespace TestProject
{
    /// <summary>
    /// 샘플 표준 크기 페이지
    /// </summary>
    public sealed partial class SampleStandardSizingPage : Page
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 이름 - FirstName

        /// <summary>
        /// 이름
        /// </summary>
        public TextBox FirstName => this.firstNameTextBox;

        #endregion
        #region 성 - LastName

        /// <summary>
        /// 성
        /// </summary>
        public TextBox LastName => this.lastNameTextBox;

        #endregion
        #region 패스워드 - Password

        /// <summary>
        /// 패스워드
        /// </summary>
        public PasswordBox Password => this.passwordPasswordBox;

        #endregion
        #region 패스워드 확인 - ConfirmPassword

        /// <summary>
        /// 패스워드 확인
        /// </summary>
        public PasswordBox ConfirmPassword => this.confirmPasswordPasswordBox;

        #endregion
        #region 선택 날짜 - ChosenDate

        /// <summary>
        /// 선택 날짜
        /// </summary>
        public DatePicker ChosenDate => this.chosenDatePicker;

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SampleStandardSizingPage()

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

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 상태 복사하기 - CopyState(page)

        /// <summary>
        /// 상태 복사하기
        /// </summary>
        /// <param name="page">샘플 컴팩트 크기 페이지</param>
        public void CopyState(SampleCompactSizingPage page)
        {
            FirstName.Text           = page.FirstName.Text;
            LastName.Text            = page.LastName.Text;
            Password.Password        = page.Password.Password;
            ConfirmPassword.Password = page.ConfirmPassword.Password;
            ChosenDate.Date          = page.ChosenDate.Date;
        }

        #endregion
    }
}

 

▶ 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>
        <Grid
            HorizontalAlignment="Center"
            VerticalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="50"   />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Frame Name="frame" Grid.Column="0" />
            <muxc:RadioButtons Grid.Column="2"
                VerticalAlignment="Center"
                Header="플루언트 표준/컴팩트 크기">
                <RadioButton
                    GroupName="ControlSize"
                    Tag="StandardSize"
                    Content="표준"
                    Checked="standardSizeRadioButton_Checked"
                    IsChecked="True" />
                <RadioButton
                    GroupName="ControlSize"
                    Tag="CompactSize"
                    Content="컴팩트"
                    Checked="compactSizeRadioButton_Checked" />
            </muxc:RadioButtons>
        </Grid>
    </Grid>
</Page>

 

▶ MainPage.xaml.cs

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

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 = "ResourceDictionary 엘리먼트 : Source 속성을 사용해 컨트롤 컴팩트 크기 사용하기";

            #endregion

            Loaded += Page_Loaded;
        }

        #endregion

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

        #region 페이지 로드시 처리하기 - Page_Loaded(sender, e)

        /// <summary>
        /// 페이지 로드시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            this.frame.Navigate(typeof(SampleStandardSizingPage), null, new SuppressNavigationTransitionInfo());
        }

        #endregion
        #region 표준 크기 라디오 버튼 체크시 처리하기 - standardSizeRadioButton_Checked(sender, e)

        /// <summary>
        /// 표준 크기 라디오 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void standardSizeRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            SampleCompactSizingPage previousPage = this.frame.Content as SampleCompactSizingPage;

            this.frame.Navigate(typeof(SampleStandardSizingPage), null, new SuppressNavigationTransitionInfo());

            if(previousPage != null)
            {
                SampleStandardSizingPage currentPage = this.frame.Content as SampleStandardSizingPage;

                currentPage.CopyState(previousPage);
            }
        }

        #endregion
        #region 컴팩트 크기 라디오 버튼 체크시 처리하기 - compactSizeRadioButton_Checked(sender, e)

        /// <summary>
        /// 컴팩트 크기 라디오 버튼 체크시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void compactSizeRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            SampleStandardSizingPage previousPage = this.frame.Content as SampleStandardSizingPage;

            this.frame.Navigate(typeof(SampleCompactSizingPage), null, new SuppressNavigationTransitionInfo());

            if(previousPage != null)
            {
                SampleCompactSizingPage currentPage = this.frame.Content as SampleCompactSizingPage;

                currentPage.CopyState(previousPage);
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형
Posted by 사용자 icodebroker
TAG , , ,

댓글을 달아 주세요