Gorilla-Player-Support
Gorilla-Player-Support copied to clipboard
Gorilla player seems to be not working in Custom controls.
Hi Team,
First of all I would like to thank you guys because you have done a great job. It helps the developer to design the view in very efficient manner and saves time a lot.
I have followed the steps as per the below documentation link and used the XLabsControls sample for a reference to achieve the requirement “Design the custom control with gorilla player” but it seems that custom controls is not working with gorilla player. So, I have reproduced the issue with your XLabsControls sample in which a custom label is derived from a label and it was registered in each platform renderer such as Android and iOS project as like below code snippet and loaded in MainPage.Xaml page.
Custom Label in PCL
public class CustomLabel : Label { public CustomLabel() { } }
Custom Label registered in Android project
[assembly: ExportRenderer(typeof(CustomLabel), typeof(CustomLabelRenderer))] namespace XLabsControlsSample.Droid { public class CustomLabelRenderer : LabelRenderer { public CustomLabelRenderer() { } } }
Custom Label registered in iOS project
[assembly: ExportRenderer(typeof(CustomLabel), typeof(CustomLabelRenderer))] namespace XLabsControlsSample.iOS { public class CustomLabelRenderer : LabelRenderer { public CustomLabelRenderer() { } } }
MainPage.Xaml
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:XLabsControlsSample;assembly=XLabsControlsSample" x:Class="XLabsControlsSample.MainPage"> <ContentPage.Content> <StackLayout> <local:CustomLabel Text="Hello GorillaPlayer" TextColor="Blue" FontSize="20"/> </StackLayout> </ContentPage.Content> </ContentPage>
It is quite strange because if I use Label directly in XAML page it works like a charm but not with custom label. Is this is a bug at your end? If no, can you please point out me what am I doing wrong in the sample. If possible can you please modify or provide a sample which elaborates to use your control in most effective way.
Steps to replicate the issue: Step 1: Open the attached sample. Step 2: Run the player either in Android or iOS platform. Step 3: Open the MainPage.Xaml and see the player is loaded with no content(issue).
Note: Other XAML pages in the sample is working properly.
Documentation Link: https://github.com/UXDivers/Gorilla-Player-Support/wiki/Gorilla-SDK Sample: XLabsControlsSample.zip
Hope you will find a solution and get back to me asap.
Thanks in Advance, Dinesh Babu Yadav
Hi @DineshBabuYadav. Thanks for your kind words and thanks for your super clear problem description :).
In Gorilla, when you try to preview a custom control you need to make sure the assembly is registered as a known assembly. In 0.9.1.2
you need to register XLabsControlSample
assembly (i.e. the assembly that contains CustomLabel
) in two places Gorilla.json
and in the configuration object created in AppDelegate.cs
and MainActivity.cs
.
So in the provided sample Gorilla.json
should look like this:
{
"knownAssemblies": [
{ "name" : "XLabs.Forms" },
{ "name" : "XLabs.Forms.Charting" },
{ "name" : "XLabsControlsSample" }
]
}
and your AppDelegate.cs
and MainActivity.cs
call to RegisterAssembliesFromTypes
should look like this .RegisterAssembliesFromTypes<ExtendedLabel, CustomLabel, Chart>()));
.
In Gorilla vNext, the registration in the Gorilla.json
is not longer required.
Hi @LeoHere ,
Thanks for the solution.
Regards, Dinesh Babu Yadav
Hi @LeoHere ,
I had a strange problem with rendering custom controls. It works but when a have a event registration in XAML, gorilla will complain about it... A workaround is to declare the events in the constructor, but this seems like a bug.
Could you please check if this is reproduce-able?
Hi @LeoHere ,
I am newbie to Gorilla player. I have checked the @DineshBabuYadav's sample with your solution. But, I am still facing the error (Gorilla SDK needed). Please find the modified sample below and please provide me helpful solution.
Sample: XLabsControlsSample.zip
Hi All,
Sorry for the delay.
We have ensured the same at our end. but still the custom controls are not rendered and facing the same issue. Can you please provide any sample for demo? Since, many of them is struggling with this one.
Hence, am reopening the issue.
Regards, Dinesh Babu Yadav
@DineshBabuYadav Did you ever figure out what was wrong?
@jadenrogers Did you tried setting up Gorilla SDK?
@LeoHere Yes that is all installed and working. Use to work fine in the same project, I thought forms 3.2 made it stop but downgrading made no effect. The funny thing is external controls render fine (like flexbutton for example) but my ones in the project don't (anymore), the break points don't get it, no attempt to run them is made. Has to be a a package or something will roll back and see what happens.
Edit: All working again, had to clean and make sure all bin and obj folders were gone and magically started working again. Upgraded to 3.2 and still working as expected. VS weirdness.
@jadenrogers
I have tried with the sample provided by @E-Mannan, the CustomLabel on the MainPage is not showing on the Gorilla player, it shows as Gorilla SDK needed on the screen,
I need the custom view to show on the gorilla player, so that i have modified the same sample with the view and changed the necessary changes on the MainActivity.cs page, it is not showing anything except a pop up "Gorilla SDK needed".
Note : I have updated Xamarin.Forms to latest 3.2 version and cleaned the Bin, Obj and restarted the Visual studio, even after this, it is not working.
The screen cast for the output and the packages used has been added below.
@SelvaKumar68
Ran your code,
The customview doesn't do anything currently and throws an error as your usage isn't valid... so just remove it and use your CustomLabel (in Main.xaml)
This works fine
<StackLayout> <local:CustomLabel Text="Custom text!! " TextColor="Red" /> </StackLayout>