Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

ListView Binding to Child Object List in an Observable collection.

$
0
0

Please forgive this if the answer is obvious.. I am fairly new to Xamarin, but not to programing or C#.
I have a ListView that works and binds just fine to the top level object and it immediate properties:

public ObservableCollection ActiveGamesCollection { get; } = new ObservableCollection();

public class GameDTOModel
{
    public int Id { get; set; }

    public string Name { get; set; }

    public string Details { get; set; }  .....

.
.

    public GameType gametype { get; set; }    // Which Type of Game is used in this game

.
... etc
}
public class GameType
{

    public int Id { get; set; }

    public string Name { get; set; }

    public virtual ICollection<Prize> Prizes { get; set; }
...etc

}

public class Prize
{
    public int Id { get; set; }

    public string Name { get; set; }

    public string ImageURL { get; set; }
...etc
}

On the main page I have a list view of available games...

        <ListView x:Name="GamesView" ItemSelected="GamesViewItemSelected">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout BackgroundColor="#eee" Orientation="Vertical">
            .... stuff ....
                            <StackLayout Orientation="Horizontal">

                ... more stuff ...
                            </StackLayout>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

The data source is in the code behind:
GamesView.ItemsSource = gamesmodel.ActiveGamesCollection;
GamesView.SelectedItem = gamesmodel.SelectedGame;
GamesView.IsPullToRefreshEnabled = true;
This all works pretty ok.
But I want to put a horizontal list of images (GameDTOModel.GameType.Prizes.ImageUrl)
But short of copying the Ilist to one directly in the GameDTOModel I cant figure out how to do it.
I see you cant nest a Listview (or shouldnt ...) I have used the syncfusion Listview to do it on the actual prize page where I have access to the objects.
I would like to do the same on he overview.
Thoughts?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>