I want to bind some properties from my code-behind .xaml.cs to some xaml-code, just like this:
<TextBlock [someProperties] ... Text="{Binding ElementName=awesome, Path=value}" />
<TextBlock [someProperties] ... Text="{Binding Path=legendary}" />
In the associated .xaml.cs file I have the property:
public String legendary = "High five";
public CoolObject awesome = new CoolObject(); //has a public property "String value = '5';"
But my TextBlocks just don’t want to show that damn “High five” and “5”. What am I missing?
And
<TextBlock [someProperties] ... Text="{Binding ElementName=awesome, Path=value}" />will not work. ElementName is used, when you want to bind to some elemnt’s in visual tree property.You need
Also you need to set TextBlock’s DataContext property to bject that contains properties you need to bind.