Hello everyone,
I'm trying to bind a Label's 'Content' property to a property from some custom type I have; unfortunately, I didn't figure out how to do it, and that's why I'm here :)
Let's assume that I have the following type (can be in the same namespace as my WPF Window that contains the Label or different namespace):
namespace MyNS
{
pubic class Person
{
private int age = 0;
public int Age
{
get { return age; }
}
public void GetOlder
{
age++;
}
}
}
1) How to I bind my Label to 'Age' property?
2) At runtime I will create an instance of 'Person'; I want to make sure that my Label is bound to the right instance; i.e. if I called:
Person SomePerson = new Person();
SomePerson.GetOlder();
I want my Lable to have the new value of 'Age' property for 'SomePerson'.
3) What if I called 'GetOlder' in different thread (whether using Dispatcher thread or BackgroundWorker)? Will I still get the latest value of 'Age'? Or do I have to take care of some other things as well to make this scenario possible?
Thanks in advance,
TheBlueSky