dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.23k stars 1.76k forks source link

Padding: Error Cannot convert value "10 12" to "Microsoft.Maui.Thickness" #15852

Closed SoyDiego closed 1 year ago

SoyDiego commented 1 year ago

Description

Hi, I have a problem when I'm trying to add Padding to my DataTrigger.

I noticed two things:

image

Steps to Reproduce

Link to public reproduction project repository

https://www.Idonthave.com

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows 10

Did you find any workaround?

No response

Relevant log output

No response

jfversluis commented 1 year ago

Does it work if you put a comma between the values?

ghost commented 1 year ago

Hi @SoyDiego. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

SoyDiego commented 1 year ago

Does it work if you put a comma between the values?

Thanks for your reply @jfversluis. It works with comma but my value before was <Setter Property="Padding" Value="10 12" /> but now I need to do like this If I want to get the design that I want: <Setter Property="Padding" Value="13,10" />. Really, very weird!

Thanks and I close the issue! :)

samhouts commented 1 year ago

Yeah, it's pretty weird behavior that this works when Hot Reloading but then fails the build when you restart. @StephaneDelcroix seems like an easy fix?

StephaneDelcroix commented 1 year ago

tl;dr: input is wrong, you get an error

Not weird at all. Grab a blanket and a hot beverage, I'll tell you a story.

Once upon a time, there was those 2 converters.

Actually not in the mood for stories, but keep the hot beverage.

XAML values are supposed to be comma separated, and the syntax for thickness one of those three

those are the values accepted by the type converter built in the compiler, and as "10 12" doesn't fit into any pattern, you get a compilation error.

The reason why HotReload accepts whitespace-separated values is that it reuse the runtime thicknesstypeconverter which also accepts CSS values, with the following format

read this again, look closely at the order of arguments, and start reconsidering all of your career choices. There are plenty of good options, mine are "goat farming in Larzac", "crafting sailboats at the highest possible location", "growing a proper beard and play the guitar in the street" (I've tried long hair already, doesn't suits me).

The bug is not "can not convert "10 12" to thickness", the actual bug is that HotReload (and LoadFromXaml, and other places) accepts both syntax

samhouts commented 1 year ago

But Stephane! I'm a web developer! I love "v h"!

And yes, I did smack myself in the forehead when I added the commas and the margins flipped.

Thanks for the additional context. :)