Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Alignment vs ContentAlignment

 
 
Old 09-23-2007   #1 (permalink)
abc


 
 

Alignment vs ContentAlignment


Consider a Window W, Button B, and TextBlock T where

W.Content = B
and
B.Content = T


T may be aligned inside B by setting B.HorizontalContentAlignment and
B.VerticalContentAlignment. However T.HorizontalAlignment and
T.VerticalAlignment have no effect.

B may be aligned inside W by setting B.HorizontalAlignment and
B.VerticalAlignment. W.HorizontalContentAlignment and
W.VerticalContentAlignment have no effect.


Is there a rule that may be deployed to determine whether these
properties should be set on the parent (using
HorizontalContentAlignment and VerticalContentAlignment) or on the
child (using HorizontalAlignment and VerticalAlignment)? It seems a bit
unfair to have to guess. The documentation is not very helpful in this
regard.


{example code follows }

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;

namespace AlignmentQuestions {
class MainWindow : Window {

[STAThread]
public static void Main() {
new Application().Run(new MainWindow());
}

public MainWindow() {
Width = 2 * 96; Height = 2 * 96;
Button button = new Button();
TextBlock text_block = new TextBlock(new Run("Button"));
button.Content = text_block;
this.Content = button;

//align text in button
//works
button.VerticalContentAlignment = VerticalAlignment.Top;

//does not work
//text_block.VerticalAlignment = VerticalAlignment.Top;


//align button in window
//does not work
//HorizontalContentAlignment = HorizontalAlignment.Left;

//works
button.HorizontalAlignment = HorizontalAlignment.Left;
}
}
}




--

Martin

My System SpecsSystem Spec
Old 10-03-2007   #2 (permalink)
Alekomar


 
 

Re: Alignment vs ContentAlignment

As I want to know answer on this question I redirect your post to
http://forums.microsoft.com/MSDN/Sho...D=119&SiteID=1

"abc" <no@xxxxxx> ???????/???????? ? ???????? ?????????:
news:%23JWyb9a$HHA.4836@xxxxxx
Quote:

>
> Consider a Window W, Button B, and TextBlock T where
>
> W.Content = B
> and
> B.Content = T
>
>
> T may be aligned inside B by setting B.HorizontalContentAlignment and
> B.VerticalContentAlignment. However T.HorizontalAlignment and
> T.VerticalAlignment have no effect.
>
> B may be aligned inside W by setting B.HorizontalAlignment and
> B.VerticalAlignment. W.HorizontalContentAlignment and
> W.VerticalContentAlignment have no effect.
>
>
> Is there a rule that may be deployed to determine whether these
> properties should be set on the parent (using
> HorizontalContentAlignment and VerticalContentAlignment) or on the
> child (using HorizontalAlignment and VerticalAlignment)? It seems a bit
> unfair to have to guess. The documentation is not very helpful in this
> regard.
>
>
> {example code follows }
>
> using System;
> using System.Windows;
> using System.Windows.Controls;
> using System.Windows.Documents;
>
> namespace AlignmentQuestions {
> class MainWindow : Window {
>
> [STAThread]
> public static void Main() {
> new Application().Run(new MainWindow());
> }
>
> public MainWindow() {
> Width = 2 * 96; Height = 2 * 96;
> Button button = new Button();
> TextBlock text_block = new TextBlock(new Run("Button"));
> button.Content = text_block;
> this.Content = button;
>
> //align text in button
> //works
> button.VerticalContentAlignment = VerticalAlignment.Top;
>
> //does not work
> //text_block.VerticalAlignment = VerticalAlignment.Top;
>
>
> //align button in window
> //does not work
> //HorizontalContentAlignment = HorizontalAlignment.Left;
>
> //works
> button.HorizontalAlignment = HorizontalAlignment.Left;
> }
> }
> }
>
>
>
>
> --
>
> Martin

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Mouse alignment Vista hardware & devices
Alignment question .NET General
Out alignment on UI windows form using .net 1.1 .NET General
Nozzle check? Alignment? Vista print fax & scan
Alignment of Printer Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46