Setting IsDirty property of a class gets Reset
RogerSchlueter-7899
1,466
Reputation points
I am reading properties into a Person class:
Public Class Person
Implements INotifyPropertyChanged
Public Property PersonID
Public Property IsDirty
....
End Class
(I've omitted details and other properties that are irrelevant.)
The data are read into an ObservableCollection (Of Person) using this subroutine:
Public Sub PopulatePeople()
....
Dim com As New SqlCommand("Get_People", con) With {.CommandType = CommandType.StoredProcedure}
Dim rdr As SqlDataReader = com.ExecuteReader
While rdr.Read
p = New Person With
{
.PersonID = rdr.GetInt32("PersonID"),
<< all the other properties >>
.IsDirty = False
}
ocPeople.Add(p)
Debug.WriteLine($"{p.PersonID} {p.IsDirty}")
End While
End Sub
That debug statement shows the correct PersonID but shows that p.IsDirty = True for every person. I can't figure out why.
Windows development | Windows App SDK
Sign in to answer