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.


--
moondaddy@newsgroup.nospam

RE: Frustrated trying to position controls in a xaml window. by wawang

wawang
Wed Jan 23 08:08:44 CST 2008

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.


Re: Frustrated trying to position controls in a xaml window. by moondaddy

moondaddy
Tue Jan 29 14:26:09 CST 2008

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.

""Walter Wang [MSFT]"" <wawang@online.microsoft.com> wrote in message
news:Z0J%239lcXIHA.4200@TK2MSFTNGHUB02.phx.gbl...
> 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.
>



Re: Frustrated trying to position controls in a xaml window. by wawang

wawang
Tue Jan 29 22:56:56 CST 2008

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.


Re: Frustrated trying to position controls in a xaml window. by moondaddy

moondaddy
Tue Feb 12 09:19:18 CST 2008

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.


""Walter Wang [MSFT]"" <wawang@online.microsoft.com> wrote in message
news:HLb$UyvYIHA.5204@TK2MSFTNGHUB02.phx.gbl...
> 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.
>