I’ve been looking again at my understanding of using container controls in a desktop app. Rather than try to type various bits of code here, I have created a tiny program which loads (And removes) several container controls, and also has small ‘flat’ style buttons (They are really rectangles made clickable).
I’m not an expert with container controls, so I’m hoping some kind soul would have a look at it and see if I have done things right.
Your approach is good but could be improved in order to make a re-useable Navigator.
Create an Event definition in the Navigator so that changing the view is done in wMain and not in the Navigator itself.
Another minor issue is the icons, when running the app on a Retina screen they aren’t retina ready.
All icons except for the “home” could be drawn directly using the graphics drawRoundRect and DrawString functions.
This would enable crisp icons on HiDPI screens.
I understand it helps keeping wMain clear, but it also means that you can’t re-use the Navigator with different items on another window.
And when you think of it, controlling the behavior of wMain should be done in wMain, not somewhere else.
If your App only has one window, or at least only one window with the Navigator then it isn’t a big issue.
But some day you might want to reuse the navigator in another App and you’ll have to update most of the code.
One rule when creating a CustomControl is to always keep code controlling an external item (in your case the Window), outside of the Control itself, usually in an Event.