Reputation: 19
At the very simplest level all I am trying to do is Data Bind TextBlock control (XAML). Am tying to get string from MyString (property defined in C# code behind) as a Text for TextBlock:
DisplayText disp = new DisplayText();
disp.MyString = "Hello";
public class DisplayText {
public string MyString {get;set;}
}
XAML code:
<TextBlock Grid.Column="1" Text="{Binding Path=MyString}" Foreground="Black"/>
But, Its not working:( Am searching for hours but could'nt get this simple thing done. Plz help!
Upvotes: 0
Views: 110
Reputation: 1
Have you seen the msdn article about data binding in Store Apps? http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh464965.aspx
The example code shows how to do what you are describing and worked for me.
Upvotes: 0
Reputation: 16695
In your XAML you need to define the DataContext.
For example:
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Also, you'll need to implement INotifyChanged if you want the screen and model to stay in sync.
Upvotes: 0