I have read multiple tutorials but most of the tutorials somehow explain it like everyone has experience with MVVM already. I do know the basics like what Model, ViewModel etc is.
Now I want to create a simple Application that has FirstName
, LastName
and a label where I want to display the FullName
later on.
Starting with the Persons Class:
public class Student
{
public string FirstName { set; get; }
public string LastName { set; get; }
public string FullName
{
get
{
return this.FirstName + " " + this.LastName;
}
}
}
This should be correct, right?
My ViewModel looks like this:
public class StudentViewModel : ViewModelBase
{
private Student _Student = new Student();
public string FirstName
{
get { return _Student.FirstName; }
set
{
_Student.FirstName = value;
NotifyPropertyChanged("FirstName");
}
}
public string LastName
{
get { return _Student.LastName; }
set
{
_Student.LastName = value;
NotifyPropertyChanged("LastName");
}
}
public string FullName
{
get { return _Student.FullName; }
}
}
Is this also correct?
Last but not least:
How do I actually display the FullName
when I press a Button?