我想提出一個視圖模型首次,一些研究之後,我得到了下面的代碼:製作一個視圖模型誤差
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HotelWPF
{
public class ReservationVM : INotifyPropertyChanged
{
public Reservation reservation = new Reservation();
private string SecretaryName;
private int RoomNumber;
private string ReservationType;
private DateTime ReservationDate;
public string SecretaryName1
{
get
{
return SecretaryName;
}
set
{
SetProperty(ref SecretaryName, value);
}
}
public int RoomNumber1
{
get
{
return RoomNumber;
}
set
{
SetProperty(ref RoomNumber, value);
}
}
public string ReservationType1
{
get
{
return ReservationType;
}
set
{
SetProperty(ref ReservationType, value);
}
}
public DateTime ReservationDate1
{
get
{
return ReservationDate;
}
set
{
SetProperty(ref ReservationDate, value);
}
}
public void SetProperty<T>(ref T store, T value, [CallerMemberName] string name = null)
{
store = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedArgs(name));
}
}
}
我收到以下錯誤:
PropertyChanged doesn't exist in current context.
也CallerMemberName給我錯了:
Type or namespace couldn't be found
作爲一年級學生很難做一個視圖模型,幫助可以理解的
編輯: 這是我的模型類之一:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HotelWPF
{
public class Reservation
{
private string SecretaryName;
private int RoomNumber;
private string ReservationType;
private DateTime ReservationDate;
public string SecretaryName1
{
get
{
return SecretaryName;
}
set
{
SecretaryName = value;
}
}
public int RoomNumber1
{
get
{
return RoomNumber;
}
set
{
RoomNumber = value;
}
}
public string ReservationType1
{
get
{
return ReservationType;
}
set
{
ReservationType = value;
}
}
public DateTime ReservationDate1
{
get
{
return ReservationDate;
}
set
{
ReservationDate = value;
}
}
}
}
to viewmodel or model class? – Gigitex
@Gigitex Viewmodel。說它正在實施INotifyPropertyChanged –
仍然收到錯誤 – Gigitex