Working with multiple views/windows
Hello!
I'm new to the Noesis GUI and I would like to use it in my game.
What is the best practive to work with multiple windows?
Under window I mean a panel, which have buttons, sliders etc.
For example if I have these windows:
- Main Menu
- Options X
- Credits
- In game panel (Health bar, current weapon's ammo, etc)
- Inventory X
- Map X
Which marked with "X", it could be visible then the "In game panel" is also visible.
How should I handle showing/hiding them? I also want to use databinding.
It should be in only 1 .xaml file, or I can separate them?
But if I separate them, how can I use data binding?
Should I use multiple NoesisView?
What happens if I want to show for example 2 inventory windows at the same time?
In WPF it's simple, I create a new instance with the specific typed window, I pass the context and I call the "Show" method.
Thank you for your help!
I'm new to the Noesis GUI and I would like to use it in my game.
What is the best practive to work with multiple windows?
Under window I mean a panel, which have buttons, sliders etc.
For example if I have these windows:
- Main Menu
- Options X
- Credits
- In game panel (Health bar, current weapon's ammo, etc)
- Inventory X
- Map X
Which marked with "X", it could be visible then the "In game panel" is also visible.
How should I handle showing/hiding them? I also want to use databinding.
It should be in only 1 .xaml file, or I can separate them?
But if I separate them, how can I use data binding?
Should I use multiple NoesisView?
What happens if I want to show for example 2 inventory windows at the same time?
In WPF it's simple, I create a new instance with the specific typed window, I pass the context and I call the "Show" method.
Thank you for your help!
-
sfernandez
Site Admin
- Posts: 3013
- Joined:
Re: Working with multiple views/windows
Hi, sorry for the late answer.
The best way to deal with different "windows" in Noesis is to define a root xaml which contains a known panel (Grid for example) where you can add the different windows. You can implement like a WindowManager that deals with the different visible windows, the z-index, and things like that.
Each of the windows can be a different xaml (UserControl) with its own ViewModel.
This will work with a single NoesisView, where you will set the root xaml and root ViewModel.
Please let us know if you need more help regarding this.
The best way to deal with different "windows" in Noesis is to define a root xaml which contains a known panel (Grid for example) where you can add the different windows. You can implement like a WindowManager that deals with the different visible windows, the z-index, and things like that.
Each of the windows can be a different xaml (UserControl) with its own ViewModel.
This will work with a single NoesisView, where you will set the root xaml and root ViewModel.
Please let us know if you need more help regarding this.
Re: Working with multiple views/windows
it's not my post, but taking advantage of the context, could you give an example of how to do this? I did mine in c++ but I think I did it wrong because I created a view for each xaml ;/
-
sfernandez
Site Admin
- Posts: 3013
- Joined:
Re: Working with multiple views/windows
First I assume there is a WindowManager that exposes a list of window view models (it can have properties like left/top position, zindex, state...).
Then you have in your XAML an ItemsControl that binds that list of windows. And that has an ItemTemplate to render each of the windows and their contents.
Every time you want to open a window, you add the desired view model to the WindowManager, which will wrap it with a window view model and add it to the list.
You have to define a DataTemplate for your view model type, so the content presenter of the window know what to render as content.
This is just a simplification, but I hope it can serve as inspiration to implement a full windowing system.
Then you have in your XAML an ItemsControl that binds that list of windows. And that has an ItemTemplate to render each of the windows and their contents.
Every time you want to open a window, you add the desired view model to the WindowManager, which will wrap it with a window view model and add it to the list.
You have to define a DataTemplate for your view model type, so the content presenter of the window know what to render as content.
This is just a simplification, but I hope it can serve as inspiration to implement a full windowing system.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests