I am a NOVICE and am very much struggling with what seems should be a very simple task. How do I modify a property of a MainWindow
TextBlock
, from ano
Use MVVM pattern
to access properties of the control and modify them:
public class Student
{
public Student()
{
}
public string Name
{
get { return "Setting Text from My Program"; }
}
}
Set the DataContext
of the XAML
in the code behind:
this.DataContext = new Student();
Bind the Text property to Name: