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

TestProject.zip
0.16MB

▶ MonkeyModel.cs

namespace TestProject.Models
{
    /// <summary>
    /// 원숭이 모델
    /// </summary>
    public class MonkeyModel
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 명칭 - Name

        /// <summary>
        /// 명칭
        /// </summary>
        public string Name { get; set; }

        #endregion
        #region 시간 - Time

        /// <summary>
        /// 시간
        /// </summary>
        public DateTime Time { get; set; }

        #endregion
    }
}

 

728x90

 

▶ MonkeyPage.xaml.cs

using TestProject.Models;

namespace TestProject;

/// <summary>
/// 원숭이 페이지
/// </summary>
public partial class MonkeyPage : ContentPage
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 생성자 - MonkeyPage()

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

        this.detailButton.Clicked += detailButton_Clicked;
    }

    #endregion

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

    #region 원숭이 상세 버튼 클릭시 처리하기 - detailButton_Clicked(sender, e)

    /// <summary>
    /// 원숭이 상세 버튼 클릭시 처리하기
    /// </summary>
    /// <param name="sender">이벤트 발생자</param>
    /// <param name="e">이벤트 인자</param>
    private async void detailButton_Clicked(object sender, EventArgs e)
    {
        MonkeyModel monkey = new MonkeyModel
        {
            Name = "홍길동",
            Time = DateTime.Now
        };

        Dictionary<string, object> dictionary = new Dictionary<string, object>
        {
            { "monkey", monkey }
        };

        await Shell.Current.GoToAsync($"//동물/원숭이/원숭이상세", dictionary);
    }

    #endregion
}

 

300x250

 

▶ MonkeyDetailPage.xaml.cs

using TestProject.Models;

namespace TestProject;

/// <summary>
/// 원숭이 페이지
/// </summary>
public partial class MonkeyDetailPage : ContentPage, IQueryAttributable
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 생성자 - MonkeyDetailPage()

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

    #endregion

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

    #region 쿼리 속성 적용하기 - ApplyQueryAttributes(queryParameterDictionary)

    /// <summary>
    /// 쿼리 속성 적용하기
    /// </summary>
    /// <param name="queryParameterDictionary">쿼리 매개 변수 딕셔너리</param>
    public void ApplyQueryAttributes(IDictionary<string, object> queryParameterDictionary)
    {
        if(queryParameterDictionary.ContainsKey("monkey"))
        {
            MonkeyModel monkey = queryParameterDictionary["monkey"] as MonkeyModel;

            if(monkey != null)
            {
                this.label.Text = $"MONKEY DETAIL PAGE : {monkey.Name}, {monkey.Time:HH:mm:ss}";
            }
            else
            {
                this.label.Text = "MONKEY DETAIL PAGE";
            }
        }
        else
        {
            this.label.Text = "MONKEY DETAIL PAGE";
        }
    }

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

댓글을 달아 주세요