Excuse me if I'll not be very clear ;-)
this is my very first project with WPF
I'd like to implement an application with a menu on the left side (a list of buttons)
Left Menu
- NEW
- UPDATE
- DELETE
- CONFIGURATION
and interchangeable views (Windows "docked" on a component) on the right.
Each view/window perform a completely different task, with his own controls, ecc...
I say Windows because so I can have the code for each window clearly separated, i don't want to mix all code in one big file...
How would you implement this?
Up to now my starting solution is like this:
When a User clicks on a Menu Button
privatevoid buttonVisualizzaScheda_Click(object sender, RoutedEventArgs e) { DockWindowRightGrid(new Test.TestDynamicLayout(), sender asButton); } privateButton activeButton = null; privateWindow activeWindow = null; privatevoid DockWindowRightGrid(Window newWindow, Button callingButton) { if (activeButton != null) { //activeButton.Background = Button.DefaultStyleKeyProperty; // How to restore default color??? } activeButton = callingButton; activeButton.Background = newSolidColorBrush(Colors.DodgerBlue); // Active button color
if (activeWindow != null) { activeWindow.Close(); } activeWindow = newWindow; activeWindow.WindowStyle = System.Windows.WindowStyle.None; activeWindow.BorderThickness = newThickness(0); activeWindow.Owner = this; activeWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual; activeWindow.Left = this.Left + 200; activeWindow.Top = this.Top + 90; activeWindow.AllowsTransparency = true; activeWindow.Width = gridContent.Width; activeWindow.Height = gridContent.Height; activeWindow.Show(); }
ONE BIG PROBLEM YET!
When the User moves the Main Window, because the actual activeWindow ins't really attached to the Main, it remains hanging in the center of the screen!!!
PS: this bug alone, let me think that mine isn't exactly the best approach I could take!!!