Tuesday, 10 September 2013

Binding a property of an object of a class inside another doesn't work

Binding a property of an object of a class inside another doesn't work

I have an strange error with binding in WPF. there is a simple sample of
what i'm doing:
public class Project
{
private string _title;
public string Title
{
get { return _title; }
set
{
_title= value;
RaisePropertyChanged("Title");
}
}
}
public class People
{
string _name
public string Name
{
get { return _name; }
set
{
_name= value
RaisePropertyChanged("Name");
}
}
private Project _project;
public Project Project
{
get { return _project; }
set
{
_project= value;
RaisePropertyChanged("Project");
}
}
}
No in in the view i bound a grid to an instance of People and it can bind
controls to Project and Name of People class,but i really can't understand
why i can not bind to Project.Title. i write my XAML code like this:
<TextBox Text="{Binding Name}"/>
<Combobox .... SelectedItem="{Binding Project}"/>
<TextBox Text="{Binding Project.Title}"/>
The first tow control above get bounded correctly but the last TextBox
doesn't.Any idea?

No comments:

Post a Comment