Link to home
Start Free TrialLog in
Avatar of wint100
wint100Flag for United Kingdom of Great Britain and Northern Ireland

asked on

WPF Navigating between Pages

Currently I have a WPF App (not Browser), that is a single Window. The Window consists of TextBlocks, Images and graphs that are updated on Timer.Tick.

This all works well, except for the slight memory leak.

What I want to do is have multiple pages to the app, that are swapped every 60s on timer.tick. I'm looking for the best way to do this. The way I've started to implement this, is to have a MainWindow.Xaml with a Frame control. The Frame.Navigate is changed on timer.Tick to link each Page.Xaml.

Is this the best way to perform this task? Ideally I'd like the pages to Transition between Page change (either Fade in/out or roll in/out etc..).

Can anyone recommened the best pratice for doing this in a WPF app before I carry on any further? I've read somewhere that Frames are for Browser apps.

Basically I'm currently creating a page for each display (dashboard) that need updating every 60s. It is very important that the page is closed properly when swapped to prevent memory leaks. So all data releated to that page is GC'd.

Thanks
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi,
   Initial you have create a window and subsequent Pages should be "userControls". When you are navigating to next page you do like below.

mainwindow.content = new SecondPage(); //secondpage is of type UserControl.

I'm also looking for functionality like this. This is what i found so far. Will share with you more if i found any
Avatar of wint100

ASKER

Currently I've created 2 Pages, and linked the Frame.Navigate to to page reference. Is this wrong?

In your example, has SecondPage been created in the project? Or are you craeting it dynamically.

Thanks, this is all new to me.
Just going through this link and hope this helps. Have to use Page instead of Frame

http://www.paulstovell.com/wpf-navigation
ASKER CERTIFIED SOLUTION
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wint100

ASKER

This looks good, will the UserControls data be GC's when closed?
Avatar of wint100

ASKER

Hi,

How would I pass the data to User control?

so Far I've Done as above with:

obj = new UserControl1(count);

How would I then use this in the UserControl? I've tried the following but the Count can not be found when used in the code:

public UserControl1(int Count)
{}




SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial