Browse Source

Fixed layout again.

Last commit actually ruined layout. Added a tab to the test app to test
that shiz.
pull/4/head
Steven Kirk 11 years ago
parent
commit
b04bcf48a1
  1. 10
      Perspex.Controls/Button.cs
  2. 2
      Perspex.Layout/Layoutable.cs
  3. 48
      TestApplication/Program.cs

10
Perspex.Controls/Button.cs

@ -48,5 +48,15 @@ namespace Perspex.Controls
add { this.AddHandler(ClickEvent, value); }
remove { this.RemoveHandler(ClickEvent, value); }
}
protected override Size MeasureOverride(Size availableSize)
{
return base.MeasureOverride(availableSize);
}
protected override Size ArrangeOverride(Size finalSize)
{
return base.ArrangeOverride(finalSize);
}
}
}

2
Perspex.Layout/Layoutable.cs

@ -197,7 +197,7 @@ namespace Perspex.Layout
size = size.WithHeight(Math.Min(size.Height, this.DesiredSize.Value.Height));
}
size = LayoutHelper.ApplyLayoutConstraints(this, finalRect.Size);
size = LayoutHelper.ApplyLayoutConstraints(this, size);
size = this.ArrangeOverride(size).Constrain(size);
switch (this.HorizontalAlignment)

48
TestApplication/Program.cs

@ -117,6 +117,7 @@ namespace TestApplication
TextTab(),
ListsTab(),
SlidersTab(),
LayoutTab(),
}
},
new TextBlock
@ -127,7 +128,7 @@ namespace TestApplication
[Grid.RowProperty] = 1,
}
}
}
},
};
window.Show();
@ -277,5 +278,50 @@ namespace TestApplication
};
}
private static TabItem LayoutTab()
{
return new TabItem
{
Header = "Layout",
Content = new Grid
{
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(1, GridUnitType.Star),
new ColumnDefinition(1, GridUnitType.Star),
},
Margin = new Thickness(50),
Children = new Controls
{
new StackPanel
{
Orientation = Orientation.Vertical,
Gap = 8,
Children = new Controls
{
new Button { HorizontalAlignment = HorizontalAlignment.Left, Content = "Left Aligned" },
new Button { HorizontalAlignment = HorizontalAlignment.Center, Content = "Center Aligned" },
new Button { HorizontalAlignment = HorizontalAlignment.Right, Content = "Right Aligned" },
new Button { HorizontalAlignment = HorizontalAlignment.Stretch, Content = "Stretch" },
},
[Grid.ColumnProperty] = 0,
},
new StackPanel
{
Orientation = Orientation.Horizontal,
Gap = 8,
Children = new Controls
{
new Button { VerticalAlignment = VerticalAlignment.Top, Content = "Top Aligned" },
new Button { VerticalAlignment = VerticalAlignment.Center, Content = "Center Aligned" },
new Button { VerticalAlignment = VerticalAlignment.Bottom, Content = "Bottom Aligned" },
new Button { VerticalAlignment = VerticalAlignment.Stretch, Content = "Stretch" },
},
[Grid.ColumnProperty] = 1,
},
},
}
};
}
}
}

Loading…
Cancel
Save