diff -r a38aec91bd66 -r a56c2baa9429 ui/wpf/UIcore/Container.cs --- a/ui/wpf/UIcore/Container.cs Sat Jan 31 11:51:54 2015 +0100 +++ b/ui/wpf/UIcore/Container.cs Sun Feb 01 10:35:07 2015 +0100 @@ -19,9 +19,8 @@ HORIZONTAL } - public class BoxContainer : Container + public class BoxContainer : Grid, Container { - public Grid Grid; public BoxOrientation Orientation; private int x = 0; @@ -29,23 +28,27 @@ private bool filled = false; - public BoxContainer(Grid grid, BoxOrientation orientation) + public BoxContainer(BoxOrientation orientation) : base() { - Grid = grid; Orientation = orientation; if(Orientation == BoxOrientation.HORIZONTAL) { RowDefinition row = new RowDefinition(); row.Height = new GridLength(1, GridUnitType.Star); - Grid.RowDefinitions.Add(row); + RowDefinitions.Add(row); } else { ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(1, GridUnitType.Star); - Grid.ColumnDefinitions.Add(col); + ColumnDefinitions.Add(col); } } + + public BoxContainer(Container parent, BoxOrientation orientation) : this(orientation) + { + parent.Add(this, true); + } public void Add(UIElement control, bool fill) { @@ -66,7 +69,7 @@ { col.Width = GridLength.Auto; } - Grid.ColumnDefinitions.Add(col); + ColumnDefinitions.Add(col); } else { @@ -85,12 +88,12 @@ { row.Height = GridLength.Auto; } - Grid.RowDefinitions.Add(row); + RowDefinitions.Add(row); } Grid.SetColumn(control, x); Grid.SetRow(control, y); - Grid.Children.Add(control); + Children.Add(control); if(Orientation == BoxOrientation.HORIZONTAL) { @@ -101,6 +104,11 @@ y++; } } + + public static BoxContainer CreateBoxContainer(Container parent, BoxOrientation orientation) + { + return Application.GetInstance().Exec(() => new BoxContainer(parent, orientation)); + } } public class GridContainer : Container