StackPanels stack, their contents only take up the space they ask for. The
buttons only want to be as big as their content and the stackpanel is
allowing that. (and is ignoring your HorizontalAlignment)
If you want to stretch the buttons to the width of their container you will
probably want to put them into a Grid which is happy to do stuff with the
HorizontalAlignment.

You learn which containers behave in which ways eventually. (I still
forget!) Each container handles the various attached properties in different
ways.

On Wed, Mar 2, 2011 at 9:39 AM, Peter Maddin <[email protected]>wrote:

> I am revisiting my UI WPF design.
>
>
>
> In the snippit below, I was expecting the two buttons to fill the entire
> space of the StackPanel while observing the margin requirements.
>
> However the two buttons are sized to their contents and not stretched.
>
>
>
>     <DockPanel LastChildFill="True">
>
>         <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" >
>
>             <Button Content="Button" Margin="20" Name="button1" 
> Click="button1_Click" HorizontalAlignment="Stretch" />
>
>             <Button Content="Button" Margin="20" Name="button2" 
> Click="button2_Click" HorizontalAlignment="Stretch"  />
>
>         </StackPanel>
>
>         <Grid >
>
>             <Ellipse  Name="ellipse1" Stroke="Black" Margin="50" />
>
>         </Grid>
>
>     </DockPanel>
>
>
>
> This does correlate with what my text WPF 4 unleashed page 104 says.
>
> Is there some other factor involved?
>
>
>
> Sorry that this such a basic question.
>
>
>
> *Regards Peter Maddin*
> *Applications Development Officer*
> *Path**West Laboratory Medicine WA*
> *Phone : +618 6396 4285
> Mobile: 0414 240 307*
> *E-Mail : [email protected]; [email protected]*
> *The contents of this e-mail transmission outside of the WAGHS network are
> intended solely for the named recipient's), may be confidential, and may be
> privileged or otherwise protected from disclosure in the public interest.
> The use, reproduction, disclosure or distribution of the contents of this
> e-mail transmission by any person other than the named recipient(s) is
> prohibited. If you are not a named recipient please notify the sender
> immediately**.*
>
>
>
>
>
> _______________________________________________
> ozwpf mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>
>
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf

Reply via email to