Skip to content

A "CardGrid" or a way to wrap a list of Cards in a CardDeck? #2458

Answered by stsrki
sturlath asked this question in Q&A
Discussion options

You must be logged in to vote

Made it work

@{
    var rows = (int)( Math.Ceiling( ListOfCards.Count() / (float)CardsPerRow ) );

    @for ( int row = 0; row < rows; row++ )
    {
        var rowIndex = row; // for some reason it doesn't work without this

        <CardDeck>
            @foreach ( var card in ListOfCards.Skip( rowIndex * CardsPerRow ).Take( CardsPerRow ) )
            {
                var index = ListOfCards.IndexOf( card ) + 1;

                <Card Margin="Margin.Is4.FromBottom">
                    <CardImage Source="assets/images/2.jpg" Alt="Placeholder image">
                    </CardImage>
                    <CardBody>
                        <CardTitle Size="5">Card title @index</CardTitle>…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sturlath
Comment options

Answer selected by sturlath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants