October 28th, 2013, 01:59 PM
2D Game Development (text based game) - Textbox focus & Best ScreenManager
Hi everyone this is my fisrt post ever so I wanted to introduce myself first
I've been using C# for quite a will and I can say that I know a little above average,
I've used XNA for game programming for 2 years now.
Recently I came up with an game ideia (text based game with a little something else ).
I always wanted to learn WPF a little more and get used to the interface, so I thought
of implementing this game ideia with WPF & XAML.
My first approach was to create a ScreenManager, the main wpf window contains a grid that
is used as a ScreenStack to hold User Controls (Screens) this way I can seperate diferent game
parts: TitleScreen, GameScreen, OptionScreen, PauseScreen..
Would you recommend a different approach? would it be better implemented in another way?
Lastly, I came up with a problem. when exchanging usercontrols, I remove the current user control
from the children list of the grid and add the new control to the list (initialize it and register its input
behavior. Everything works fine.. but this new screen I load contains a TextBox that should be
automaticly focused. I managed to get the caret to be there but it isn't blinking (I need to press the
TAB button before typing) :/
I've used Focus (during the initialization phase) - doesn't work!!
I've used Keyboard.Focus(textbox) - doesn't work!!
Start this screen (the one containing the textbox) first - Works!!
Use a title screen before that afterwards calls this one - doens't work!!
So I think it must be a bad "ScreenManager" implementation.. what do you think?
Sorry if it is too confusing :/ I can post some code if you want.
Thank you for the time and dedication
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!