views:

77

answers:

3

I have a UI with some controls, then in the middle I have 6 overlapping grids. I am using these grids as 'pages' and as the user navigates through the 'pages' I cycle through using Visible.Hidden and Visible.Visible to show the correct 'page'.

I noticed while developing as I was adding more grids the application started to slow down (a lot). It wasn't really a problem until I added 6 more images to the last page. Since, the application is very slow even on my (faster than average) PC.

Do you have any advice on how I can still achieve the same look and feel but use a more efficient method?

Thanks in advance.

+1  A: 

I suggest that you use the WPF Frame and Page classes instead of your current architecture. As with any presentation framework, performance degrades as you add more controls to your scene graph.

Michael S. Scherotter
A: 

TabControl with a custom template?

kyoryu
+3  A: 

All in all it's not a good idea to have a bunch of overlapping controls like you have, because as you noticed, there are performance problems. You want to minimize the number of controls which are present in your application at any one time.

If you have a limited number of pages, use TabControl.

If you have a large or dynamic number of pages, consider Frames and Pages.

A third option is to have a hosting "shell" control with a ContentPresenter. Then whenever you want to navigate to a different page, just set the control's Content to a new instance of your page view.

Your views are separate from your data models, right? If not, consider using the MVVM pattern. This will allow you to have persistent data regardless of which view is showing (e.g. dynamically creating and destroying views won't mess up your data).

emddudley
The TabControl seems to be what I would need to use. However, I need the background to be transparent and the actual tabs to be invisible.Any ideas?
Zinefer
If you use a custom template for your tab control then you'll be able to set the style of the tab control to anything you want. I would also note that I've had some problems with performance and tabcontrols in the past. I would recommend emddudley's third option of the ContentPresenter and setting the content (Composite UI).
Chris Nicol