■ PageFunction<T> 클래스를 사용하는 방법을 보여준다.
▶ TestPageFunction.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<PageFunction x:Class="DS.Test.WPF.TestPageFunction" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" x:TypeArguments="s:String" Title="TestPageFunction"> ... </PageFunction> |
▶ TestPageFunction.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
/// <summary> /// 테스트 페이지 함수 /// </summary> public partial class TestPageFunction : PageFunction<string> { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 값 /// </summary> private string value; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - TestPageFunction() /// <summary> /// 생성자 /// </summary> public TestPageFunction() { InitializeComponent(); } #endregion #region 생성자 - TestPageFunction(value) /// <summary> /// 생성자 /// </summary> /// <param name="value">값</param> public TestPageFunction(string value) : this() { this.value = value; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region OK 버튼 클릭시 처리하기 - okButton_Click(sender, e) /// <summary> /// OK 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void okButton_Click(object sender, RoutedEventArgs e) { OnReturn(new ReturnEventArgs<string>(this.value)); } #endregion #region Cancel 버튼 클릭시 처리하기 - cancelButton_Click(sender, e) /// <summary> /// Cancel 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void cancelButton_Click(object sender, RoutedEventArgs e) { OnReturn(new ReturnEventArgs<string>(null)); } #endregion } |
▶ CallTestPageFuncation.xaml
1 2 3 4 5 6 7 8 9 10 11 |
... <Hyperlink Name="hyperlink" Click="hyperlink_Click"> 테스트 페이지 함수 호출 </Hyperlink> ... |
▶ CallTestPageFuncation.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
... #region 테스트 페이지 함수 리턴시 처리하기 - testPageFunction_Return(sender, e) /// <summary> /// 테스트 페이지 함수 리턴시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void testPageFunction_Return(object sender, ReturnEventArgs<String> e) { if(e.Result != null) { Console.WriteLine(e.Result); } } #endregion #region 하이퍼링크 클릭시 처리하기 - hyperlink_Click(sender, e) /// <summary> /// 하이퍼링크 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void hyperlink_Click(object sender, RoutedEventArgs e) { TestPageFunction testPageFunction = new TestPageFunction("TestString"); testPageFunction.Return += new ReturnEventHandler<string>(testPageFunction_Return); NavigationService.Navigate(testPageFunction); } #endregion |