![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| 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 | |||