UXDivers / Gorilla-Player-Support

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

Gorilla SDK not showing data when bound to a ItemsSource Bindable Property #307

Open npagare opened 6 years ago

npagare commented 6 years ago

Hello, In the Gorilla mode, I don't see ListView rendereing data that is bound to a ItemsSource bindable property defined in the code behind of a user control (implemented as a ContentView).

Your help in addressing this issue will be appreciated.

My XAML User Control (say myUserControl.xaml) is made up of ContentView has a ListView. In the code behind I have declared the ItemsSource Property as a bindable property, as shown below. // BINDABLE PROPERTY ItemSource : Used to pass set of data items depending on the category of the data elements public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create("ItemsSource", typeof(IEnumerable), typeof(myUserControl));

    public IEnumerable ItemsSource
    {
        get
        {
            return (IEnumerable)GetValue(ItemsSourceProperty);
        }
        set
        {
            SetValue(ItemsSourceProperty, value);
        }
    }

In the myUserControl.xaml - I have defined ListView as

<ContentView.Content>
    <ListView
        CachingStrategy="RecycleElement"
        HasUnevenRows="true"
        ItemSelected="OnItemSelected"
        ItemsSource="{Binding ItemsSource, Source={x:Reference Name=x_this}}"
        SeparatorVisibility="None">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                             ……...
               </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

This usercontrol is referenced in another ContentView (say parentContentView.xaml) as shown below

When I tried to browse the parentContentView.xaml in the iOS simulator, it dosen's show up any data. Any thoughts to address this issue ?

Thanks,

npagare commented 6 years ago

TestData currently defined under @Global.

As a result, I also tried setting the BindingContext of my userControl in two was as shown below; still it is not working.

Method 1

Method 2

"{Binding TestData}" What’s the name of the viewmodel / class and its namespace that holds mashalled data from DesignTimeData.json file? I can try using that as the BindingConext value.
npagare commented 6 years ago

Can someone please respond ?

LeoHere commented 6 years ago

@IoTFier Design time data should be defined in the DesignTimeData.json. You associate the data to a given page by defining a property with the name of the XAML page you want to attach the data to. See this wiki entry for more information.

Please notice that any logic/code you define in the code behind will not be executed by Gorilla.

If you are still having issues, please create a tiny XF project where the problem is illustrated.

npagare commented 6 years ago

Hi @LeoHere , my sample data is in the DesignTimeData.json. In this case I have defined 4-5 json data (sets) under @ Global My goal is to provide different set of data by name as declared under @ global in side each instance of the controlview template that contains my listview having the bindable itemsource property.

So, as example if I have TestData1, TestData2, TestData3 defined under @ global then, the binding will look like below; but I don't know how to specify the BindingContext in this case. That's because Gorilla is having a viewmodel internally which looks like builds a data collection at runtime from all the JSON data defined in the DesignTimeData.json. I would like to provide the name of that viewmodel from Gorilla loaded at runtime in the bindingcontext below.

Method 1

Is there a new update on the Goriall Dev version?

Thanks

npagare commented 6 years ago

Hi @LeoHere, I am still waiting for your input. Also, is there a new dev version of the Gorilla SDK/player that you can share with me?

Thanks

LeoHere commented 6 years ago

@IoTFier the binding context is implicitly set for you by Gorilla. If you have 3 collections in @Global, as you described, you should be able to access them as bellow.

<userControl:myUserControl ItemsSource="{Binding TestData1}"  />
<userControl:myUserControl ItemsSource="{Binding TestData2}" />
<userControl:myUserControl ItemsSource="{Binding TestData3}" />

Those collections are merged with the design time data you defined for you page (in case you did that), so they became available as collections in you current binding context.

npagare commented 6 years ago

Hi @LeoHere , this approach doesn't work when I have a listview with a ItemSource defined as a bindable property defined in the code. Please take a look at my original request in this issue.

Thanks