Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Sat, 22 Sep 2007 23:59:58 -0700,    group: microsoft.public.windows.developer.winfx.avalon        back       


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
date: Sat, 22 Sep 2007 23:59:58 -0700   author:   abc

Re: Alignment vs ContentAlignment   
As I want to know answer on this question I redirect your post to 
http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=119&SiteID=1

"abc"  ???????/???????? ? ???????? ?????????: 
news:%23JWyb9a$HHA.4836@TK2MSFTNGP06.phx.gbl...
>
> 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
date: Wed, 3 Oct 2007 11:58:18 +0300   author:   Alekomar alekomar

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us