I am using WPF MVVM for a project. I have 8 View/ViewModel pairs that work well for the solution, but I have found myself duplicating two event handlers in code-behind for each View: OnLoaded and ExpandDetail (which is needed to respond to a request for more detail on a line in a DataGrid)
Moving them to the ViewModelBase (so each ViewModel would have the code) is not practical because they refer to WPF framework elements that in the View.
I believe they are rightly view oriented routines.
I get than old ugly feeling when having to repeat them in each view. Does anyone have advice about how I might get them into one, usable location?
What I have tried:
I have not tried it yet, but each view is a usercontrol, so I have thought about trying the idea of a ViewBase UserControl to base everything on but it seems kludgy.
I have searched the usual sources, with no results. I'm hoping someone has found a solution to this kind of thing that I can adapt