■ Binding 태그 확장 : ElementName 속성을 사용해 엘리먼트 바인딩 하기

------------------------------------------------------------------------------------------------------------------------


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"

    FontSize="36">

    <Grid x:Name="page" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

        <StackPanel

            Orientation="Horizontal"

            HorizontalAlignment="Center"

            VerticalAlignment="Top">

            <TextBlock>&#x21A4;&#x00A0;</TextBlock>

            <TextBlock Text="{Binding ElementName=page, Path=ActualWidth}" />

            <TextBlock>픽셀</TextBlock>

            <TextBlock>&#x00A0;&#x21A6;</TextBlock>

        </StackPanel>

        <StackPanel

            Orientation="Vertical"

            HorizontalAlignment="Center"

            VerticalAlignment="Center">

            <TextBlock HorizontalAlignment="Center">&#x21A5;</TextBlock>

            <StackPanel

                HorizontalAlignment="Center"

                Orientation="Horizontal">

                <TextBlock Text="{Binding ElementName=page, Path=ActualHeight}" />

                <TextBlock>픽셀</TextBlock>

            </StackPanel>

            <TextBlock HorizontalAlignment="Center">&#x21A7;</TextBlock>

        </StackPanel>

    </Grid>

</Page>

 

 

MainPage.xaml.cs

 

 

using Windows.UI.Xaml.Controls;

 

namespace TestProject

{

    /// <summary>

    /// 메인 페이지

    /// </summary>

    public sealed partial class MainPage : Page

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainPage()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainPage()

        {

            InitializeComponent();

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG