[FrmWrite.xaml]


<UserControl x:Class="RiaMultiPage.FrmWrite"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

   

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel>

            <TextBlock Text="여기는 글쓰기 페이지" FontSize="30"></TextBlock>

            <Button x:Name="btnList" Content="리스트 페이지로 이동" />

        </StackPanel>

    </Grid>

</UserControl>

 

 





[FrmWrite.xaml.cs]


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaMultiPage

{

    public partial class FrmWrite : UserControl

    {

        public FrmWrite()

        {

            InitializeComponent();

            this.btnList.Click += new RoutedEventHandler(btnList_Click);

        }

 

        void btnList_Click(object sender, RoutedEventArgs e)

        {

            MainPage mp = this.Parent as MainPage; mp.Navigate(new FrmList());

        }

    }

}

 

 





[FrmList.xaml]


<UserControl x:Class="RiaMultiPage.FrmList"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

   

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel>

            <TextBlock Text="여기는 리스트 페이지" FontSize="30"></TextBlock>

            <Button x:Name="btnWrite" Content="글쓰기 페이지로 이동" />

        </StackPanel>

    </Grid>

</UserControl>

 

 





[FrmList.xaml.cs]


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaMultiPage

{

    public partial class FrmList : UserControl

    {

        public FrmList()

        {

            InitializeComponent();

 

            this.btnWrite.Click += new RoutedEventHandler(btnWrite_Click);

        }

 

        void btnWrite_Click(object sender, RoutedEventArgs e)

        {

            // 메인 페이지(나의 부모) Navigate 메서드 호출

            MainPage mp = this.Parent as MainPage;

 

            // 이동 메서드 호출

            mp.Navigate(new FrmWrite());

        }

    }

}

 

 







[MainPage.xaml]


<UserControl x:Class="RiaMultiPage.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

</UserControl>

 

 





[MainPage.xaml.cs]


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaMultiPage

{

    /// <summary>

    /// 컨테이너 역할 : 다른 UserControl 인클루드 시켜주는 역할

    /// </summary>

    public partial class MainPage : UserControl

    {

        public MainPage()

        {

            InitializeComponent();

 

            //[!] 처음 로드시에는 FrmList.xaml 로드

            if (this.Content == null)

            {

                this.Content = new FrmList(); // 리스트 페이지를 기본으로...

            }

        }

 

        //[!] 페이지 이동 메서드

        public void Navigate(UserControl nextPage)

        {

            // 현재(MainPage) 내용을 새로운 UserControl 변경

            this.Content = nextPage;

        }

    }

}

 

 















'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글

Navigation Framework 사용  (0) 2009.12.08
Navigation Application  (0) 2009.12.08
OOB(Out Of Browser)  (0) 2009.12.08
Image Deep Zoom  (0) 2009.12.07
Effect (효과)  (0) 2009.12.07
Posted by holland14
: