I am building a WPF application that uses the simple MVVM and EF architecture.
I see a strange problem if, if I try to set the datetime property, I get a System.StackOverflowException . If I do not set the datetime property, I get no exception.
Binding:
<DatePicker Style="{StaticResource Dp}" Grid.Column="1" SelectedDate="{Binding Date, UpdateSourceTrigger=PropertyChanged}" />
Public property:
public DateTime Date { get { return _criticalDate.Date; } set { if (_criticalDate != null && value != null && _criticalDate.Date == value) return; _criticalDate.Date = value; OnPropertyChanged("Date"); } }
Trying to get through it with the debugger does not work. I looked at everything, trying to understand what was happening ... any hints of what might be causing this?
This is the definition for the CriticalDate class,
public partial class CriticalDate { public int ID { get; set; } public System.DateTime Date { get; set; } public string CriticalReason { get; set; } public int FileID { get; set; } }
The _criticalDate field is a private instance of the CriticalDate class. CriticalDate is a class created by EF from my DB schema. He himself is not a DateTime .
FINAL UPDATE
I still donโt know what happened ... I tore off the offensive section (including the binding) and rewrote it from scratch. I donโt know what I did differently, but now it works. I think this was due to the way the control element was configured ... if I had more time (silly terms), I would come back to see what it was, but so far it's a mystery.
Thanks for sharing my confusion, if only ever so briefly.
c #
Chronicide
source share