I have the following:
A MainWindow;
with Children on the MainGrid in the MainWindow:
- ContentControl, displays the main content of the program and has a taskbar at the bottom for user interaction
- AddContentControl, shall be started via ContentControl, a control that allows the user to add content to the ContentControl
- TakePictureControl, shall be started from AddContentControl, allows the user to take a picture via webcam
- CropControl, shall be started from TakePictureControl after the Picture was taken, because the image has to be square
- SettingsControl, shall be started from ContentControl, allows to change the settings of the program
So basically I have the following hierarchy:
MainWindow<-MainGrid<-The five controls, only one visible at a time
Since controls are childs of the MainGrid/Window, I can’t access the initialized objects of the control.
What I want is the following:
- Stay in one window
- access a control from another control
- pass arguments to a control from another control (e.g. image from TakePhotoControl to CropControl)
- code that is easy to understand and object oriented
What I had earlier was that I did not encapsulate the controls, so I had the main logic in the MainWindow.xaml.cs and all UI elements sitting directly on the MainGrid. Positive was that I could access everything I wanted. Negative is that this was horrible to read (and it will get worse), not comfortable to edit, not object oriented and barely reusable.
How do I solve my issue?
4