Finding the Bound property, from a UIElement, after it has been bound

Case:

public class customer
{
    public string Adress { get; set; }
}

Xaml:


 
 
 

.cs

 public MainPage()
 {
 InitializeComponent();
 LayoutRoot.DataContext = new customer() { Adress = "Some Adr" };
 }

So the Question is, in code behind. how do I get the property (string) of the bound (Adress). I need it to access the customer.adress as a property, to assign another variable. (in this case when a event occours. e.g. after the this.Loaded occurs.)

So I got the UIElement (sender) and I can get the customer form its DataContext.

In short, how do I get the property name of the binding object. (the binding object is easy to find I just use DataContext to get the customer, but where can I get the name of the property? that are in the xaml (eg. name) from the sender)

(I plan to use reflection if it is nessesery to access the "adress" inside customer) but how to get the "name" of the property that text in the textBox is bound to.

1
задан Dave Clemmer 6 September 2013 в 22:17
поделиться