Not getting result without giving DataContext
Hi Everyone,Why student name is not displayed while executing the code untill I give this.DataContext = objstudent;
anyhow I am bindingstudentname here in xaml right.Please help me out.
xaml part:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"> </RowDefinition>
</Grid.RowDefinitions>
<TextBox Name="TextBox1" Text="{Binding Path=StudentName}"></TextBox>
</Grid>
Code behind:
public MainWindow()
{
InitializeComponent();
Student objstudent = new Student();
objstudent.StudentName = "sharmi";
}
public class Student
{
private string studentname;
public string StudentName
{
get
{
return studentname;
}
set
{
studentname = value;
}
}
}