Hi ,
I'm a bit lost , how to bind this to my view ?
the view is not list , it retrun one voucher and only one
var VouchersPart = new Voucher
{
VoucherID = 50533960,
OfferID = 122,
StartDate = Convert.ToDateTime("2018-10-11T00:00:00"),
ExpiryDate = Convert.ToDateTime("2019-02-01T00:00:00"),
Conditions = null,
Message = "test",
CategoryName = "New year offers",
SubCategoryName = null,
Description = "fdf",
CtcID = 2826091,
CustomerName = "User",
Redeemed = true
}
Posts
Tutorial site:
http://redpillxamarin.com/2018/03/12/2018-101-vs2017-new-solution/
@ClintStLaurent can't find anything like this at that website !
really? 3 minutes of looking and you can't find anything on how to do binding?
Please don't be offended when I say I don't think you looked very hard or tried to walk through the series.
No - there is not an exact page pre-made for your exact class and properties. However 70% of the site focuses on how to do proper app architecture and then how to bind so you don't have tons of code behind.
Your question is "How do I do binding if this is my object class?" - that's what it boils down to. how do I do binding?
So start at the beginning. And build the sample app and learn how to do binding. Then apply that understanding to the app you are building.
http://redpillxamarin.com/2016/12/14/introduction-to-this-series/
and..
http://redpillxamarin.com/2017/01/28/206-reusable-controls/
http://redpillxamarin.com/2018/04/12/2018-103-base-classes/
https://redpillxamarin.com/2017/01/08/401-revisiting-mvvm/
@ClintStLaurent thank you for your fast answer ,
yes i'm a bit lost , I know how to bind a list but , for this example i'm a bit lost , and the blue blog i couldn't find the search part at first .
Any way , thank you .
Ok. So for a
ListView
you bind the.Source
property to anObservableCollection
on your ViewModel. You say you already understand that. Great.So for your class object its not much different. You have properties that you would want to bind to various UI elements on your view.
Assuming you have a voucher on your ViewModel named
CurrentVoucher
, just as an example:@ClintStLaurent
alright , that's work , but this is gonna need more code , instead of using a list view I need a grid than!?
Right. A
Grid
or aStackLayout
or a combination therof.A
ListView
is for binding collections of the same type. If you had a collection ofVoucher
you would using aListView
but you'd still have to create aDataTemplate
for how to display each property of the object in the cell of theListView
@ClintStLaurent it started to work , a bit ugly , but it's working !
thank you for the help .
here is what i'm working on :
I gotta change make the page similar to the version on webview , still thinking about the design but it must be look close to it
web part

mobile

Glad you got it working.
and the problem is with the list , it most be only for view ,must not be tapped , and make enable=false change it's color that's bad..