Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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:
C#
FooWindow fooWindow = new FooWindow();  //A separate window with controls
this.ClientPanel.Children.Add(fooWindow.ClientGrid);  //The grid I want to swap in

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.
:-)
Posted
Updated 25-Jan-12 9:17am
v2
Comments
theanil 25-Jan-12 15:17pm    
Added tags.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900