<PageFunction
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="NavigationApplication.SelectProductPageFunction"
Title="SelectProductPageFunction"
xmlns:local="clr-namespace:NavigationApplication"
x:TypeArguments="local:Product">
<StackPanel>
<ListBox Name="lstProducts">
<ListBoxItem>A</ListBoxItem>
<ListBoxItem>B</ListBoxItem>
<ListBoxItem>C</ListBoxItem>
</ListBox>
<TextBlock Grid.Row="1">
<Hyperlink Click="lnkOK_Click">OK</Hyperlink>
<Hyperlink Click="lnkCancel_Click">Cancel</Hyperlink>
</TextBlock>
</StackPanel>
</PageFunction>
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
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 NavigationApplication
{
public partial class SelectProductPageFunction
{
public SelectProductPageFunction()
{
InitializeComponent();
}
private void lnkOK_Click(object sender, RoutedEventArgs e)
{
ListBoxItem item = (ListBoxItem)lstProducts.SelectedItem;
Product product = new Product(item.Content.ToString());
OnReturn(new ReturnEventArgs<Product>(product));
}
private void lnkCancel_Click(object sender, RoutedEventArgs e)
{
OnReturn(null);
}
}
public class Product
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
public Product(string name)
{
Name = name;
}
}
}
|