Page 1 of 1

Game dialog/window layout

Posted: 29 Mar 2014, 15:36
by jc_lvngstn
I remember a previous discussion on this but can't find the thread.
I currently have this as my main UI Window:
<Canvas
   Name="UI_MainWindow"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   xmlns:UserControls="clr-namespace:UserControls"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   mc:Ignorable="d">
   <Grid Name="UI_Windows">

      
   </Grid>
</Canvas>

All my my game windows such as inventory, or a dialog window, etc are just UserControls. When I want to show one, I just create the usercontrol via code and add it to the "UI_Windows" children via this:

GetChildren().Add(newWindow);

This works ok...except when some windows are added as children, they distort the other windows. They will resize if I add another window, to match its height at times.
I don't know if this is because UI_Windows is a grid control.

Is there a better way to add/remove dynamic windows to the UI, without affecting others? Should I just remove the parent UI_Windows grid control, and add new Usercontrols inside their own canvases and set their positions, etc?
Thanks,
JC

Re: Game dialog/window layout

Posted: 29 Mar 2014, 16:23
by matt.rudder
Your biggest problem here, is the grid is stretching to fit the largest child element you have added. Since there are no row or column definitions defined every element takes up the entire grid space.

If you want the structure of the Grid, you'll have to add the rows and columns to your Grid as shown here: http://noesisengine.com/docs/Gui.Core.L ... orial.html

For something like this though, I would probably get rid of the grid altogether (or make UI_Windows a canvas) and add your window elements to the canvas. Then you can position your UserControls wherever you see fit via attached properties, like so:
canvas.GetChildren().Add(newWindow);
canvas.SetLeft(newWindow, windowX);
canvas.SetTop(newWindow, windowY);

Re: Game dialog/window layout

Posted: 29 Mar 2014, 21:47
by jc_lvngstn
How frustrating. I could have sworn I tried this already, it's a pretty obvious solution. /bonk bonk

Regardless..thanks for you help, it works great!

Re: Game dialog/window layout

Posted: 02 Jun 2019, 06:11
by whidbey
my vote of 5

Re: Game dialog/window layout

Posted: 03 Jun 2019, 12:13
by jsantos
Please, do not resurrect old threads that are marked as solved. Create new ones. Thanks!

Re: Game dialog/window layout

Posted: 03 Jun 2019, 16:30
by whidbey
Please, do not resurrect old threads that are marked as solved. Create new ones. Thanks!
ok,sorry,i just want to bookmark it. just find the function;