New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Auto for Width and Height properties #1601
Comments
In WPF: In addition to acceptable Double values, this property can also be Double.NaN. This is how you specify auto sizing behavior in code. In XAML you set the value to the string "Auto" (case insensitive) to enable the auto sizing behavior. Auto sizing behavior implies that the element will fill the height available to it. Note however that specific controls frequently supply default values through their default theme styles that will disable the auto sizing behavior unless it is specifically re-enabled. |
Wow, I didn't even know this was supported in WPF. Yes we should do this too. |
That would be great, I came across this when doing docking control, without Auto (from code you have to set double.NaN) its impossible to position correctly the controls automatically using DockPanel for my docking control. |
@grokys Not sure how currently Avalonia/src/Avalonia.Layout/Layoutable.cs Lines 75 to 85 in 44da9df
So actually |
@grokys Looks like I don't need <DockPanel LastChildFill="True" Background="Pink">
<DockPanel LastChildFill="True" Width="180" DockPanel.Dock="Left">
<Border Background="Red" Width="180" Height="250" DockPanel.Dock="Top"/>
<Border Background="Blue" Width="180" Height="NaN" DockPanel.Dock="Bottom"/>
</DockPanel>
<DockPanel LastChildFill="True" Width="240" DockPanel.Dock="Right">
<Border Background="Green" Width="240" Height="250" DockPanel.Dock="Top"/>
<Border Background="Orange" Width="240" Height="NaN" DockPanel.Dock="Bottom"/>
</DockPanel>
<Grid>
<Border Background="Gray" Width="300" Height="300"/>
</Grid>
</DockPanel> Anyway in the feature implementing support for |
This would involve adding a DoubleConverter the rest is just straight forward. |
And also something like |
Is there a workaround for this that already exists? |
|
That doesn't seem to work (maybe I'm doing something wrong). I would imagine that my XAML:
|
Do you need HorizontalAlignment set to Stretch? |
I don't think that was required in the WPF world, but even so - setting |
I know I'm resurrecting an old thread, but derek, what's the content of the ComboBox? Auto (or NaN) only takes up as much space as it needs, so if there is no contents in it, it will be tiny. "*" will fill. In your example, the first ColumnDefinition sets it to Auto, and then the StackPanel only takes up as much space as it needs, along with the ComboBox (which is inside the StackPanel), if it's empty, doesn't need more than what it does. |
I ended up hardcoding the width ( |
It works now with Combobox.HorizontalAlignment set to Stretch. |
Height="NaN" does not work for elements. Such as TextBox, ToggleSwitch, etc. They all have predefined heights and would be nice to be able to set to auto. |
Repro:
Exception:
The text was updated successfully, but these errors were encountered: