Example about native UX components doesn't work

I hate doing this, but it is the same as https://www.fusetools.com/community/forums/general/creating_native_controls

I’m trying to implement a custom native control, however, the examples contained in https://www.fusetools.com/docs/native-interop/native-ux-components don’t work. I can compile the file .uno containing the MySlider component (for Android), but when I add the following snippet :

namespace MyWrappers.Android
{
    extern(!Android) public class MySlider: LeafView
    {
        public float Value { get; set; }
    }
}

the following message appears : There is nothing named 'LeafView' accessible in this scope. Did you perhaps misspell 'ILeafView' (as in 'Fuse.Controls.Native.ILeafView')? Could you be missing a package reference?

Fine, the documentation is wrong. After fixing it, the next uno build -t android gives me the following:

> uno build -t android

Uno 0.29.20 (build 2873) OS X 10.11 i386 eb56555

Configuring
MainView.ux(6): E8001: Fuse.Controls.PropertyBinding`1<float> cannot be used here, because there are no suitable parent nodes in this scope.
MainView.ux(6): E8001: 'MySlider does not expose a bindable property called 'AndroidTemplate'
MainView.ux(9): E8001: 'MySlider does not expose a bindable property called 'GraphicsTemplate'
(6.98s)

Build completed in 6.98 seconds.
    0 Warning(s)
    3 Error(s)

The MainApp.ux is below:

<App>
    <StackPanel>
        <Control ux:Class="MySlider">
            <float ux:Property="Value" />

            <MyWrappers.Android.MySlider ux:Generate="Template" ux:Binding="AndroidTemplate" Value="{Property this.Value}" />
        <!--    <MyWrappers.iOS.MySlider ux:Generate="Template" ux:Binding="iOSTemplate" Value="{Property this.Value}" /> -->

            <Text ux:Generate="Template" ux:Binding="GraphicsTemplate">
                MySlider is not available in this context.
            </Text>
        </Control>

        <Text> HEY! </Text>

    </StackPanel>
</App>

So, what should I do to implement a native control? (it seems LeafView doesn’t implement AndroidTemplate and GraphicsTemplate)

Hi!

First you need to add

using Fuse.Controls.Native.Android;
using Uno.Compiler.ExportTargetInterop;

to you uno file for the LeafView class to be visible in your code.

Our docs for custom native views are a bit out of date, I’ll make sure that gets fixed ASAP.

ux:Generate="Template" ux:Binding="AndroidTemplate" has changed to ux:Template="AndroidAppearance"

Thanks!

However, it still doesn’t work and I can’t figure out what’s happening.

The line

<MyWrappers.Android.MySlider ux:Template="AndroidAppearance" Value="{Property this.Value}" />

now gives me E8001: Fuse.Controls.PropertyBinding`1<float> cannot be used here, because there are no suitable parent nodes in this scope.

(Removing the line compiles just fine but it won’t display the native component on Android.)

I wish I could avoid these stupid questions, but as you said, the documentation is outdated =/