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

TestProject.zip
다운로드

▶ 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"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <Grid Name="grid"
            HorizontalAlignment="Center"
            VerticalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
        </Grid>
    </Grid>
</Page>

 

728x90

 

▶ MainPage.xaml.cs

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

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

        #region 생성자 - MainPage()

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

            DisplayInformation displayInformation = DisplayInformation.GetForCurrentView();

            AddRow(this.grid, "CurrentOrientation"     , displayInformation.CurrentOrientation     );
            AddRow(this.grid, "DiagonalSizeInInches"   , displayInformation.DiagonalSizeInInches   );
            AddRow(this.grid, "LogicalDpi"             , displayInformation.LogicalDpi             );
            AddRow(this.grid, "NativeOrientation"      , displayInformation.NativeOrientation      );
            AddRow(this.grid, "RawDpiX"                , displayInformation.RawDpiX                );
            AddRow(this.grid, "RawDpiY"                , displayInformation.RawDpiY                );
            AddRow(this.grid, "RawPixelsPerViewPixel"  , displayInformation.RawPixelsPerViewPixel  );
            AddRow(this.grid, "ResolutionScale"        , displayInformation.ResolutionScale        );
            AddRow(this.grid, "ScreenHeightInRawPixels", displayInformation.ScreenHeightInRawPixels);
            AddRow(this.grid, "ScreenWidthInRawPixels" , displayInformation.ScreenWidthInRawPixels );
            AddRow(this.grid, "StereoEnabled"          , displayInformation.StereoEnabled          );
        }

        #endregion

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

        #region 행 추가하기 - AddRow(grid, caption, value)

        /// <summary>
        /// 행 추가하기
        /// </summary>
        /// <param name="grid">그리드</param>
        /// <param name="caption">제목</param>
        /// <param name="value">값</param>
        private void AddRow(Grid grid, string caption, object value)
        {
            grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

            int rowIndex = grid.RowDefinitions.Count - 1;

            TextBlock textBlock = new TextBlock();

            textBlock.Margin              = new Thickness(0, 1, 10, 1);
            textBlock.HorizontalAlignment = HorizontalAlignment.Right;
            textBlock.VerticalAlignment   = VerticalAlignment.Center;

            textBlock.Text = caption;

            grid.Children.Add(textBlock);

            Grid.SetRow   (textBlock, rowIndex);
            Grid.SetColumn(textBlock, 0       );

            TextBox textBox = new TextBox();

            textBox.Margin              = new Thickness(0, 1, 0, 1);
            textBox.HorizontalAlignment = HorizontalAlignment.Left;
            textBox.VerticalAlignment   = VerticalAlignment.Center;


            textBox.Text = value.ToString();

            grid.Children.Add(textBox);

            Grid.SetRow   (textBox, rowIndex);
            Grid.SetColumn(textBox, 1       );
        }

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

댓글을 달아 주세요