I was creating a MonthPicker
and noticed that Visual Studio 2019 Community (16.9.4) calls property of ViewModel before instantiating it. Here's what it does:
so here's it's gotten into the setter of QueryEditablePlot
and tells that EditablePlots
is null although it's been initialized in the constructor. This is the first time I've seen such an issue and it's been happening since this morning. To get rid of that error, I've to set a breakpoint in the constructor and let it hit that point and go. The problem for this question is EventManager.RegisterClassHandler
in custom FrameworkElement
.
I've two custom FrameworkElement, DayPicker
and MonthPicker
. In the constructor of DayPicker I've this:
EventManager.RegisterClassHandler(typeof(MonthYear), MonthYear.MouseUpEvent, new RoutedEventHandler(onMonthYearClicked), true);
EventManager.RegisterClassHandler(typeof(Day), Day.MouseUpEvent, new RoutedEventHandler(onDayClicked), true);
and in the constructor of MonthPicker this:
EventManager.RegisterClassHandler(typeof(MonthYear), MonthYear.MouseUpEvent, new RoutedEventHandler(onMonthYearClicked), true);
both of the MonthYear
and Day
are custom FrameworkElement
. Now, when I click on my DayPicker
button to open popup and select a Day
, that day becomes selected in every DayPicker
in the entire application:
If I type in the date, without clicking on Day
, it behaves as expected. In the MonthPicker
I have MonthYear
, no Day
. Now when I go to decade/year mode and select a decade/year in the MonthPicker, all of my DayPicker
go into decade/year mode:
How to change this behavior? I want it to affect only the DayPicker
or MonthPicker
I clicked.