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

■ MultiBinding 엘리먼트의 StringFormat 속성을 사용하는 방법을 보여준다.

TestProject.zip
0.15MB

▶ Employee.cs

namespace TestProject
{
    /// <summary>
    /// 직원
    /// </summary>
    public class Employee
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 이름 - FirstName

        /// <summary>
        /// 이름
        /// </summary>
        public string FirstName { get; set; }

        #endregion
        #region 성 - LastName

        /// <summary>
        /// 성
        /// </summary>
        public string LastName { get; set; }

        #endregion
    }
}

 

▶ MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="TestProject.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:TestProject">
    <ContentPage.BindingContext>
        <local:Employee
            FirstName="길동"
            LastName="홍" />
    </ContentPage.BindingContext>
    <Label
        HorizontalOptions="Center"
        VerticalOptions="Center"
        FontSize="32">
        <Label.Text>
            <MultiBinding StringFormat="{}{0} {1}">
                <Binding Path="LastName"  />
                <Binding Path="FirstName" />
            </MultiBinding>
        </Label.Text>
    </Label>
</ContentPage>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요