I am creating a WPF CustomControl that has a dependency property with PropertyChangedCallback. In that Callback method I try to set values on some of the control's parts that I retrieve from OnApplyMethod using the GetTemplateChild() method.
The problem is that the PropertyChangedCallback is (on some systems) called before OnApplyTemplate so the control parts are still null.
The workaround I'm currently using is to save e.NewValue from the PropertyChangedCallback to a member variable and then call SetValue(dp, _savedValue) in OnApplyTemplate().
What is the proper way to deal with this problem or am I already using the best solution?