Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / February 2008

Tip: Looking for answers? Try searching our database.

Frustrated trying to position controls in a xaml window.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moondaddy - 23 Jan 2008 08:25 GMT
I'm trying to position controls in a window and am having a very difficult
time.  I want all the controls to be anchored top/left so when I do the
final resizing of the window, all the controls sit in the same position.
However, as I place controls toward the right side of the form, the left
alignment changes to right, and the margin changes from ##,##,0,0 ##,##,##,0
to 0,##,##,0.  so to position the control just as I want, I have to
painfully edit he margin values.  In some cases, when the control is on the
right side of the form and the control has the value of ##,##,0,0, the left
margin is not what I would expect and the control repositions its self in a
place that doesn't make sense.  Also the widths keep changing on me.  This
is a royal pain.

What am I doing wrong?

Thanks.

Signature

moondaddy@newsgroup.nospam

Walter Wang [MSFT] - 23 Jan 2008 14:08 GMT
Hi,

I'm not sure if I've fully understood your question. Are you referring to
the Visual Studio 2008's XAML designer here? Have you tried Expression
Blend 2?

Also, please refer to "Alignment, Margins, and Padding Overview"
(http://msdn2.microsoft.com/en-us/library/ms751709.aspx) for more concept
on the positioning of WPF elements.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
moondaddy - 29 Jan 2008 20:26 GMT
Using expression is not an option right now.

I have a window or usercontrol which has a grid in it.  in the grid, I
wanted to place a bunch of controls such as texboxes, combo boxes, etc.  If
I want to position them in rows (4 across and 3 down.), first I set the
controls to:
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="0,0,0,0"

then I drag them into position.  The controls on the right side will
automatically be reset to HorizontalAlignment="Right"  which is really
annoying and make  formatting UIs very time consuming.

Thanks.

> Hi,
>
[quoted text clipped - 17 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Walter Wang [MSFT] - 30 Jan 2008 04:56 GMT
Hi,

I see your points here. However, I think the designer is trying to make a
guess that the elements at the right half side of the container will have
"Right" horizontal alignment so that they can stick to the right side when
the container is being resized.

Actually, I would suggest you to manually edit the XAML code first to
declare the columns and rows for the Grid; after that, when you drag & drop
elements on the Grid, the designer will automatically set
column/row/columnspan/rowspan of them and will not change the alignments.

   <Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="100" />
           <ColumnDefinition Width="100" />
           <ColumnDefinition Width="*" />
       </Grid.ColumnDefinitions>
       <Grid.RowDefinitions>
           <RowDefinition Height="50" />
           <RowDefinition Height="50" />
           <RowDefinition Height="50" />
           <RowDefinition Height="*" />
       </Grid.RowDefinitions>

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
moondaddy - 12 Feb 2008 15:19 GMT
Thanks Walter.  I did that, however, when vs changes these properties to
it's best guess, it also changes the behavior when the window is resized, so
once again, I loose control of what I'm trying to do.  I'm using a canvas
now and don't have the problem anymore.

> Hi,
>
[quoted text clipped - 33 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.