<Window x:Class="BookApp.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BookApp" Height="300" Width="300">
<Grid>
<Button Click="MyClickEvent" Name="btnGo">Go</Button>
</Grid>
</Window>
//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.Shapes;
namespace BookApp
{
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
Book x = new Book();
x.author = "A";
x.title = "title";
x.price = (decimal)9.99;
Application.Current.Properties["Book"] = x;
}
private void MyClickEvent(object sender, RoutedEventArgs e)
{
Book y = (Book)Application.Current.Properties["Book"];
MessageBox.Show(y.title, y.author, MessageBoxButton.OK,MessageBoxImage.Hand);
}
}
public class Book
{
public decimal price;
public string title;
public string author;
}
}
|