Forum Xamarin.Forms

i want images in a carousel view from table row

h_kumarh_kumar Member ✭✭

i want to bind images (ie. table field name - image1, image2, image3, image4, image5 ) data row from table (not a coulum Data) to carousel view.
can anyone help me out solving this issue plz.....


  • LandLuLandLu Member, Xamarin Team Xamurai

    Do you mean you only have one record in your table?
    If so, define a class containing these fields to retrieve data from your database. Then iterate each property to get the corresponding values. Create a new list to access these values.
    At last, set your carousel view's items source to this list.
    But it looks weird to do so. Why not place all your images in one name called image?

  • h_kumarh_kumar Member ✭✭
    edited July 2019

    hi @ladnlu
    thanks for spending your time for my issue.
    lets check out the table....
    Id | Name | Unit | Desc | Detail | Rate | smlImg | MedImg1 | MedImg2 | medImg3 | LargeImg1 | largeImg2 | LargeImg3 |

    1 xyx
    2 abc
    3 aaa
    4 bbb

    i actually have ProductListPage where i retrieve data using jsonconverter. (using Viewmodel - ProductView.cs, Model Products.cs) which provides me all column of the table and i show there Name, Price, Desc and SmlImg data in listview.
    now using ListView_ItemTapped event my ProductListPage gets navigate to ProductDetailPage and there i need to show there row data of that Particular Id... and i m showing there MedImg1, MedImg2 and MedImg3..... **thats why there i only have to use one record in table..... **

    ok and the additional information is that i used varbinary(max) datatype to store images into table
    now why i want this coz i want all images on the ProductDetailPage to get swipe left and right.. so i thought my purpose gets solved if i can bind them into carousel view... and i don't then need to go use swipe gesture if this works.

    ok so as u say i think i must place all my images in one name called image.... i also thought so and i tried doing so but couldn't get succeeded as yet....

    it would be very helpful if u guide me to place / bind all my images in one name called image...
    thanks a lot
    u also can suggest me whether idea to bind all images (of Particular Id) to swipe left and right on ProductDetailPage is good or not or i should use swipe gesture ?
    i m new to xamarin so i m not 100% sure and clear what to use where....
    thank u again

  • LandLuLandLu Member, Xamarin Team Xamurai
    edited July 2019

    @h_kumar You have defined a Products model to access your json string. It must contain the property named image1, image2 and image3...
    Then the detail page could get the single Product model at the initial time. You could create a list as your carousel view's items source and add your images there. i.e.

    // ...

    However, I think the better way is to create an image json array column to present your images.

  • h_kumarh_kumar Member ✭✭
    @thanks for yr reply...
    Hey I tried but unable to do so can u plzexplain in detail...
Sign In or Register to comment.