Forgive me as I am fairly new to WPF.
I have a small app with a grid at the bottom that extends the width of the window (for navigation buttons) and a grid that fills up the rest of the window, a "client area". I also have separate windows defined in XAML that are basically one grid (the size of my client area) with various controls, etc. that I want to swap in and out as a result of pressing the navigation buttons.
In my button handlers, I can do this programmatically no problem:
this.ClientPanel.Clear();
Grid myGrid = new Grid();
this.ClientPanel.Children.Add(myGrid);
What I NEED to do is to use the grids I have developed in XAML from my other windows.
I tried:
FooWindow fooWindow = new FooWindow();
this.ClientPanel.Children.Add(fooWindow.ClientGrid);
However, this fails at runtime. It says I need to "disconnect" the grid from the window. Exactly! I don't even want the window. I just want the grid.
What's the easiest way to do this? Can you define a grid as a resource? Should it be a user control?
Any help would be appreciated.
:-)