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:DesignWidth='640'
d:DesignHeight='480'>
HorizontalAlignment="Left" Margin="15,0,0,0"/>
//File:Page.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
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;
using System.Collections.Generic;
using System.ComponentModel;
namespace SilverlightApplication3
{
public class Address : INotifyPropertyChanged
{
private string location;
private string address1;
private string address2;
private string city;
public event PropertyChangedEventHandler PropertyChanged;
public string Location
{
get { return location; }
set
{
location = value;
NotifyPropertyChanged("Location");
}
}
public string Address1
{
get { return address1; }
set
{
address1 = value;
NotifyPropertyChanged("Address1");
}
}
public string Address2
{
get { return address2; }
set
{
address2 = value;
NotifyPropertyChanged("Address2");
}
}
public string City
{
get { return city; }
set
{
city = value;
NotifyPropertyChanged("City");
}
}
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));
}
}
}
public partial class MainPage : UserControl
{
private Address theAddress;
public MainPage()
{
InitializeComponent();
theAddress = new Address();
Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{
AddressGrid.KeyDown += new KeyEventHandler(AddressGrid_KeyDown);
}
void AddressGrid_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.C && Keyboard.Modifiers == ModifierKeys.Control)
{
theAddress.Location = "address";
theAddress.Address1 = "Boston!";
theAddress.Address2 = "1 Blvd";
theAddress.City = "CA";
}
if (e.Key == Key.M && Keyboard.Modifiers == ModifierKeys.Control)
{
theAddress.Location = "B";
theAddress.Address1 = "Way";
theAddress.Address2 = "Building 10";
theAddress.City = "WA";
}
this.DataContext = theAddress;
}
}
}