TomaszRewak / C-sharp-console-gui-framework

A GUI framework for C# console applications
MIT License
1.08k stars 45 forks source link

Expanding elements without using `Box` #14

Closed kbilsted closed 4 years ago

kbilsted commented 4 years ago

Just learning the framework. Is this as expected? I thought it required a ´Box´ in order for the content to be centered.

class Program
{
    static void Main(string[] args)
    {
        ConsoleManager.Setup();
        ConsoleManager.Resize(new Size(150, 40));

        ConsoleManager.Content =

                new Border()
                {
                    Content =
                        new HorizontalStackPanel()
                        {
                            Children = new[] { new TextBlock { Text = "Hello world" }, new TextBlock { Text = "22Hello world22" }, }
                        }
                }
            ;

        Console.ReadKey();
    }

image

TomaszRewak commented 4 years ago

Do you want to center to border or the text within it?

kbilsted commented 4 years ago

I'm just reading the docs and trying it out. eg

Box
Aligns the Content control vertically (Top/Center/Bottom/Stretch) and horizontally (Left/Center/Right/Stretch).

HorizontalStackPanel
Stacks multiple controls horizontally.

since I'm not using Box i dont understand why the content is maxmized. Perhaps details are missing in the docs?

TomaszRewak commented 4 years ago

The Border will always take all of the available space when not stored in a control that defines a different layout behavior. The only way to center elements is using the Box control. The proper way of implementing it is described in #13