dotnet / MobileBlazorBindings

Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
MIT License
1.2k stars 168 forks source link

Unable to load image from URL #464

Open davidortinau opened 1 year ago

davidortinau commented 1 year ago
<Image Source="https://github.com/davidortinau/davidortinau/blob/da46072934f03036e55c5b4e9bdff8483a1767cd/davidortinau_2019.png"/>

Throws compile error:

/Users/davidortinau/work/mbbstarter/mbbstarter/MainPage.razor(17,34): error CS1525: Invalid expression term ')' [/Users/davidortinau/work/mbbstarter/mbbstarter/mbbstarter.csproj]

Dreamescaper commented 1 year ago

Seems like a https://github.com/dotnet/razor-compiler bug, probably due to implicit conversion to ImageSource. Works fine this way:

<Image Source=@("https://raw.githubusercontent.com/davidortinau/davidortinau/da46072934f03036e55c5b4e9bdff8483a1767cd/davidortinau_2019.png") />

Alternatively you can have it as field, it will probably be a bit better from performance perspective:

<Image Source="_image " />

@code {
   ImageSource _image = "https://raw.githubusercontent.com/davidortinau/davidortinau/da46072934f03036e55c5b4e9bdff8483a1767cd/davidortinau_2019.png";
}