Gorilla-Player-Support icon indicating copy to clipboard operation
Gorilla-Player-Support copied to clipboard

Error: No Property of name ImageProperties.ImageName found (v0.8.3.0 SDK)

Open ntrhieu89 opened this issue 8 years ago • 15 comments

I use the Gorilla Player SDK to try displaying the custom image markup. The code below is the mark up code.

 namespace MyNamespace {  
   [ContentProperty("Source")]
    public class ImageResourceExtension : IMarkupExtension {
        public string Source { get; set; }
        public object ProvideValue(IServiceProvider serviceProvider) {
            if (Source == null)
                return null;
            return ImageSource.FromResource(Source);
        }
    }
 }

In the XAML file, I add an assembly to help finding this class xmlns:local="clr-namespace:MyNamespace;assembly=MyNamespace"

And try to display an image in my page:

      <StackLayout Orientation="Horizontal"> 
        <Image Source="{local:ImageResource MyNamespace.Assets.usd-32.png}" VerticalOptions="Center"/>
        <Label Text="Bills" VerticalOptions="Center"/>        
      </StackLayout>

This is the content of Gorilla.json:

{
    "knownAssemblies":[
    {
      "name": "UXDivers.Artina.Shared---REMOVED",
      "types": null
    },
    {
      "name": "MyNamespace",
      "types": null
    },
    {
      "name": "MyNamespace.Assets",
      "types": null
    }
    ]
}

However, Gorilla Player (embedded in my app) denies to display it: XAML: No Property of name ImageProperties.ImageName found

Details of the error please see the attached files issue-1 issue-2

Am I missing anything, or this is a bug in Gorilla?

ntrhieu89 avatar May 10 '16 22:05 ntrhieu89

I encountered exactly the same issue today. When displaying the Page without Gorilla the Page works fine

escamoteur avatar Sep 07 '16 09:09 escamoteur

Hi @escamoteur, can you provide more details about what you where trying to preview?

LeoHere avatar Sep 09 '16 09:09 LeoHere

Exacrfly like the thread starter I tried to load an embedded image that is in the main assembly

escamoteur avatar Sep 09 '16 11:09 escamoteur

Ok. I was able to reproduce the issue. Even if we fix this particular issue, you will not be able to preview the embedded images as you originally intended to. This is not supported right now. I will mark it with the feature request label.

If anyone besides you two guys need this feature let me know.

LeoHere avatar Sep 12 '16 12:09 LeoHere

Thanks Leo! Hope this feature would be available soon, this the above example is a pretty common use case.

ntrhieu89 avatar Sep 14 '16 06:09 ntrhieu89

Ok! Got it. Thanks for your feedback!

LeoHere avatar Sep 14 '16 09:09 LeoHere

Anything new on that? Or what is your recommendation if I want to design pages with static images in it? Where should I place them?

escamoteur avatar Oct 04 '16 14:10 escamoteur

Same problem here, I think static image is a useful feature to support. However, I will try to use a dummy binding as workaround for now...

ShiroYacha avatar Oct 04 '16 21:10 ShiroYacha

Dummy binding to what? I helped me that I put some images on my webserver and referenced them via url, Do Icons work?

escamoteur avatar Oct 04 '16 21:10 escamoteur

It's just an ugly workaround if static embedded resource is really needed. It prevents the gorilla from breaking but it won't show the image (same as using Local images).

Just self-bind the image source to code behind: BindingContext="{x:Reference Root}" Source="Binding IconSource, Mode=OneWay}" and public ImageSource IconSource => ImageSource.FromResource("XXX.Resources.logo.png"); and use the instructions on Xamarin Working with Images to setup the embedded images. Since embedded resource need the ImageResourceExtension, the SampleData.json won't work.

PS: you can set the backgroundcolor just for design time usage with Gorilla (i assume the contour will work just fine for the layout).

ShiroYacha avatar Oct 04 '16 21:10 ShiroYacha

Any solution for Embedded Images?

orafique82 avatar Dec 04 '16 10:12 orafique82

Any news on this, I am a new Xamarin/Gorilla developer, I use a Converter to load the images, when I need them, based on values in the underlying data. The convert is being fired fine using the sdk method, however return ImageSource.FromResource("XXX.Content.Images.image.png"); doesn't work, the form however loads fine without gorilla.

JasonColeyNZ avatar Mar 12 '17 08:03 JasonColeyNZ

Came here looking for a fix to the same problem. Hope you guys find the time to include this into the player.

Shadowing01 avatar Aug 25 '17 07:08 Shadowing01

If anyone besides you two guys need this feature let me know.

As @LeoHere asked; this is a huge issue for us, many of our images are embedded in the same assembly as the XAML. I'm trying to think of a workaround that will at least have Gorilla not crash, even if the images don't show up.

nexussays avatar Jul 18 '18 05:07 nexussays

Ditto here. Been struggling with this for two days now.

DolenzSong avatar Mar 27 '19 22:03 DolenzSong