question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for Auto for Width and Height properties

See original GitHub issue

Repro:

<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="Auto" 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="Auto" DockPanel.Dock="Bottom"/>
    </DockPanel>
    <Grid>
        <Border Background="Gray" Width="300" Height="300"/>
    </Grid>
</DockPanel>

Exception:

Portable.Xaml.XamlObjectWriterException
  HResult=0x80131500
  Message=Could not convert object 'Auto' (of type System.String) to {http://schemas.microsoft.com/winfx/2006/xaml}Double: Auto is not a valid value for Double.
  Source=Avalonia.Markup.Xaml
  StackTrace:
   at Portable.Xaml.XamlObjectWriterInternal.GetCorrectlyTypedValue(XamlMember xm, XamlType xt, Object value)
   at Portable.Xaml.XamlObjectWriterInternal.StoreAppropriatelyTypedValue(ObjectState state, MemberAndValue ms, Object obj, Object keyObj)
   at Portable.Xaml.XamlObjectWriterInternal.OnWriteValue(Object value)
   at Portable.Xaml.XamlServices.Transform(XamlReader xamlReader, XamlWriter xamlWriter, Boolean closeWriter)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.LoadFromReader(XamlReader reader, AvaloniaXamlContext context, IAmbientProvider parentAmbientProvider)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Stream stream, Assembly localAssembly, Object rootInstance, Uri uri)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Type type, Object rootInstance)
   at Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(Object obj)
   at Core2D.Avalonia.Views.MainControl.InitializeComponent() in D:\DOWNLOADS\GitHub-Avalonia\Core2D\src\Core2D.Avalonia\Views\MainControl.xaml.cs:line 26
   at Core2D.Avalonia.Views.MainControl..ctor() in D:\DOWNLOADS\GitHub-Avalonia\Core2D\src\Core2D.Avalonia\Views\MainControl.xaml.cs:line 18

Inner Exception 1:
Exception: Auto is not a valid value for Double.

Inner Exception 2:
FormatException: Input string was not in a correct format.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
grokyscommented, May 19, 2018

Wow, I didn’t even know this was supported in WPF. Yes we should do this too.

0reactions
pavlovsgcommented, May 5, 2022

I ended up hardcoding the width (Width="190"), but haven’t tried this with a newer version of Avalonia since I originally posted this.

It works now with Combobox.HorizontalAlignment set to Stretch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow 'auto' value for width/height attributes of image tags ...
1 Answer 1 ... While the CSS attributes width and height support the auto value, the HTML attributes width and height do not...
Read more >
Setting Height And Width On Images Is Important Again
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
Read more >
Everything About Auto in CSS
In CSS, we have the value auto which could be used for properties like margin, positioning, height, width, and a lot more.
Read more >
CSS Height, Width and Max-width
The height and width properties are used to set the height and width of an element. The height and width properties do not...
Read more >
Explore auto layout properties
You can set minimum or maximum width and height to any auto layout frame and its children. Open the Width dropdown to find...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found