• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Basic design question for designing multi-screen guis

R

rain73@gmail.com

#1
I'm working on a simple game in WPF. Here is my problem: I want to
have a login where the user goes through a series of screens to login.
In Java, I've implemented this kind of thing by defining a panel to
hold the login screens. Then when the user advances to the next
screen, the currently displayed panel is removed from the parent panel
and the new panel is added.

I'm confused about how to replicate this behavior in WPF while taking
advantage of XAML. If I were to make my WPF completely code based with
no xaml, I could use the same technique that I used in Java (each
screen would be a class that extends a panel such as StackPanel). But
as far as I can tell, if I make a XAML/Code class in WPF, it has to be
either a window or a page. I can't make a XAML file with <StackPanel>
or some other panel as the root element.

I've read a bit about the Frame element but I'm not sure if this is
the right approach to take (hosting each login screen inside the frame
and advancing to the next "page").

Any ideas? I'm clearly just missing some key idea on how WPF works.
I've been thinking about this problem and reading documentation for
countless hours and so any help you could provie would be greatly
appreciated. Thanks!
 

My Computer

P

Plamen Ratchev

#2
One way to implement what you need would be to use a Frame and then load
XAML defined pages (just set the source for the Frame to the next page). The
Frame will be just one of the elements in your window, you can have
StackPanel and other content there too (and you can use Grid, StackPanel,
etc. to arrange the Frame position).

Another way is to use a NavigationWindow for container and add Pages. Then
you can use the NavigationService to move between page. This can provide you
a little bit extra power as the NavigationService works similar to your
browser. It can go back and forward between pages (with GoBack or GoForward,
or directly Navigate).

HTH,

Plamen Ratchev
http://www.SQLStudio.com
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)