Simple databinding in WPF issue

  • Thread starter Thread starter RDA
  • Start date Start date
R

RDA

Hey all, I'm having a tough time conducting a simple databinding
procedure in XBAP. Here's my code:

<Page x:Class="WPF_IBS.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">

<TextBox x:Name="personNameTextBox" Text="{Binding Path=Name}" />
</Page>


Here's the namespace:

namespace WPF_IBS
{

class Person
{
string name = "No Name";

public string Name
{
get { return name; }
set { name = value; }
}
}

public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();

Person person = new Person();

this.DataContext = person;
}
}
}


This is the entirety of my code. I can not get this simple process to
work. What am I doing wrong??
 
Your Person object needs to implement the INotifyPropertyChanged
interface or the Name property needs to be a DependencyProperty or you
need to manually update the binding on change.
 
Your Person object needs to implement the INotifyPropertyChanged
interface or the Name property needs to be a DependencyProperty or you
need to manually update the binding on change.

Thank you very much for the response! Could you please provide an
example of any of those suggestions? I'm trying to implement
System.ComponentModel.INotifyPropertyChanged but it's not working...
 
Back
Top