UXDivers / Gorilla-Player-Support

This is the public Gorilla Player support website
http://gorillaplayer.com
115 stars 17 forks source link

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

Open ntrhieu89 opened 8 years ago

ntrhieu89 commented 8 years ago

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?

escamoteur commented 8 years ago

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

LeoHere commented 8 years ago

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

escamoteur commented 8 years ago

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

LeoHere commented 8 years ago

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.

ntrhieu89 commented 8 years ago

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

LeoHere commented 8 years ago

Ok! Got it. Thanks for your feedback!

escamoteur commented 8 years ago

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?

ShiroYacha commented 8 years ago

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...

escamoteur commented 8 years ago

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

ShiroYacha commented 8 years ago

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).

orafique82 commented 7 years ago

Any solution for Embedded Images?

JasonColeyNZ commented 7 years ago

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.

Shadowing01 commented 7 years ago

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

nexussays commented 6 years ago

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.

DolenzSong commented 5 years ago

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