Click here to Skip to main content
15,886,091 members
Articles / Desktop Programming / WPF

WPF PageFunction Object

Rate me:
Please Sign up or sign in to vote.
3.63/5 (5 votes)
27 Feb 2009CPOL2 min read 46K   1.4K   9  
This article demonstrates the use of the WPF PageFunction object in Page based WPF applications.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPF.PageBasedApplication
{
    /// <summary>
    /// Interaction logic for HomePage.xaml
    /// </summary>
    public partial class HomePage : Page
    {
        public HomePage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //Create instance of PageFunction
            PageFunction apage = new PageFunction();
            //Attach the Return EventHandler to Handle ReturnEventAgrs passed from PageFunction            
            apage.Return += new ReturnEventHandler<object>(apage_Return);
            
            //Navigate to Page Function
            NavigationService.Navigate(apage);
        }

        /// <summary>
        /// Return EventHanlder Method to ReturnEventAgrs passed from PageFunction
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void apage_Return(object sender, ReturnEventArgs<Object> e)
        {
            //Display the Items selected
            List<string> selectedItems = (List<string>)e.Result;
            foreach (string item in selectedItems)
            {
                listBox1.Items.Add(item);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Sachin has been developing software professionally for more than five years. Mostly working with .NET Framework 3.5/3.0/2.0/1.x, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF)\Smart Client, ASP.NET 3.5/2.0/1.x (WebForm), XAML, ASP.NET AJAX 1.0, C# (3.0), LINQ, VB.NET, ADO.NET, WinForm, Web Services, MS Sync Framework, Window Services, UI Automation Framework, SQL Server and good experience in agile/scrum development methodology.

Comments and Discussions