Hello guys I recently got started with windows store apps development and right now I'm studying data binding. I looked up at the MSDN for examples and tried running it but I keep getting an error this is the code I'm working on
This is my Mainpage.xaml file
<Grid x:Name="LayoutRoot" Background="#FF0C0C0C">
<TextBox x:Name="textBox1" Text="{Binding}" FontSize="30"
Height="120" Width="440" IsReadOnly="True"
TextWrapping="Wrap" AcceptsReturn="True" />
</Grid>
This is Mainpage.xaml.cs file
// Constructor
public MainPage()
{
InitializeComponent();
// Set the data context to a new Recording.
textBox1.DataContext = new Recording("Chris Sells", "Chris Sells Live",
new DateTime(2008, 2, 5));
// Theres an error message that says textBox1 does not appear in the current context though i have declared it in the MainPage.xaml file
}
// A simple business object
public class Recording
{
public Recording() { }
public Recording(string artistName, string cdName, DateTime release)
{
Artist = artistName;
Name = cdName;
ReleaseDate = release;
}
public string Artist { get; set; }
public string Name { get; set; }
public DateTime ReleaseDate { get; set; }
// Override the ToString method.
public override string ToString()
{
return Name + " by " + Artist + ", Released: " + ReleaseDate.ToString("d");
}
}
I keep getting an error message at my MainPage.xaml.cs file that:
textbox1 doesnt exits
although it is in the MainPage.xaml file.