WPF textblock binding question.
Posted
by the empirical programmer
on Stack Overflow
See other posts from Stack Overflow
or by the empirical programmer
Published on 2010-05-19T23:27:00Z
Indexed on
2010/05/19
23:30 UTC
Read the original article
Hit count: 196
wpf
|databinding
I'm trying to get my head around the whole MVVM thing and binding. I have a ViewModel class which has a property that is another class. I want to bind to a (string) property of that class to the text of a textblock.
I set the ViewModel as my data context for my window\page. And then do this:
<TextBlock Text="{Binding ElementName=myAddressClass, Path=StreetName}" />
But this does not work. The text is empty.
I can expose the StreetName directly as below and this works:
<TextBlock Text="{Binding Path=StreetName}" />
So am I doing something wrong in the first example. It seems simple enough ... am I just confuse about what an elementname is or should be set to?
thanks
© Stack Overflow or respective owner