AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.88k stars 2.24k forks source link

Unable to cast object of type 'System.Double' to type 'Avalonia.Thickness' #16523

Open lunarcloud opened 3 months ago

lunarcloud commented 3 months ago

Describe the bug

Upgraded from Avalonia 11.0.11 to 11.1.1 - and now the application won't startup because of an InvalidCastException

To Reproduce

Specify a thickness. Seems to be specifically not liking:

<Style Selector="TabItem /template/ Border#PART_SelectedPipe">
    <Setter Property="BorderThickness" Value="{DynamicResource TabStripItemPipeThickness}" />
</Style>

Expected behavior

It to continue working, for it to figure out how to turn a number into a thickness.

Avalonia version

11.1.1

OS

Windows

Additional context

Is fixed by changing it to

<Style Selector="TabItem /template/ Border#PART_SelectedPipe">
    <Setter Property="BorderThickness" Value="2" />
</Style>
maxkatz6 commented 3 months ago

A bit conflicted here. TabStripItemPipeThickness is a type of double, while BorderThickness expects a Thickness. This exception is expected.

But seems like previously it was implicitly converted. cc @grokys

jpgarza93 commented 3 months ago

Having same issue here and the stacktrace does not contain the name of the xaml element or file where it is happening :(

MrScottyTay commented 3 weeks ago

I'm getting a similar issue too and like the person above me, it's really hard to discern where this is happening due to it not saying where the issue occured