jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Game dialog/window layout

29 Mar 2014, 15:36

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
 
User avatar
matt.rudder
Posts: 21
Joined: 24 May 2013, 08:12
Location: San Francisco, CA
Contact:

Re: Game dialog/window layout

29 Mar 2014, 16:23

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);
 
jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Re: Game dialog/window layout

29 Mar 2014, 21:47

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!
 
whidbey
Posts: 49
Joined: 26 May 2019, 07:16

Re: Game dialog/window layout

02 Jun 2019, 06:11

my vote of 5
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Game dialog/window layout

03 Jun 2019, 12:13

Please, do not resurrect old threads that are marked as solved. Create new ones. Thanks!
 
whidbey
Posts: 49
Joined: 26 May 2019, 07:16

Re: Game dialog/window layout

03 Jun 2019, 16:30

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;

Who is online

Users browsing this forum: No registered users and 2 guests