Simple databinding in WPF issue

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??
 
N

not_a_commie

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.
 
R

RDA

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top