Mega Code Archive
Bind to an Existing Object Instance
//File:Window.xaml.cs
using System.Windows;
namespace WpfApplication1
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
this.DataContext = new Employee()
{
FirstName = "A",
LastName = "B",
Age = 26
};
}
}
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
}