I am new to the silverlight. I found some articles on the internet for databinding. I can see that binding is performed in different ways as follows
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Path=Name}"/>
<TextBlock Text="{Binding Path=Account}"/>
<TextBlock Text="{Binding Path=Property1.Property2.Property3}"/>
In the first textblock binding is performed with property name. In second example also binding is performed with property name. Then what is different with Path in second textblock ? I know how to do binding for the first three textblock but I am not aware how to do binding with the fourth textblock ? and when we use the binding of the following type
<TextBlock Text="{Binding Path=Property1.Property2.Property3}"/>
Can you please give me coding example along with explanation for all above thing ? If I misunderstood something then please guide me.
By using the following binding:
You’re saying that the data context of the
TextBlockhas a property calledProperty1, which returns an object that has a property calledProperty2, which in turn has a property calledProperty3. The value returned byProperty3is what will be shown in theTextBox.For example, if your classes looked like this and the data context for the
TextBoxwas an instance ofFoo, you’d see “Hello World” displayed:The “
.” syntax just lets you refer to “subproperties” of an object. For more information, take a look at this MSDN article.