Implementing a static ListView

Houssem Dellai
A free video tutorial from Houssem Dellai
Currently working at Microsoft, ex Microsoft MVP
4.1 instructor rating • 4 courses • 30,767 students

Learn more from the full course

I want to connect my Xamarin Forms app to REST API

In less than 3hours, learn how to create a REST API with ASP.NET Core and call it from Xamarin Forms app (iOS & Android)

02:18:15 of on-demand video • Updated March 2018

  • Develop mobile app prototype
  • Understand how REST web services works with mobile apps
  • Implement CRUD operations' calls with user interface
English [Auto] Let's learn how to create a list of you and I said hours on my forms application instead of showing a simple label which holds the view of to do items and those items doesn't come from our service but if you take the view hosted in our application but later we see how we can call the web services that we created that returns the list view from our database was an azure. So let's start here. We see that the first application or the first page that we allow is the main page the main page is the one right here. Sort of XML page and XML That's the page will go to the XML space and we'll define our list of you so from here I go and override that gold and appear on that the ring will be executed in its time. This page will appear and from here and go and define my dues as you list. So for the list here I need to add in namespace which is here system that collections genetic in order to be able to use the least to this list. I need to pass the type of the items of the list and the type here should be the to do model but to do right here doesn't exist in my current summary forms. Look next on that project but it does exist in my web. AB I have created it inside this modalist folder. So what they will do here I will copy this to do a class from my API project to build a nest on that project. Go and paste it here. And just make the change here to change the namespace to use this in namespace as my as my many forms application which use your to do up grade so I have a copy of the modem. Now I can use it from my main page to say that here the list should be a list of two. Now I passed data to those to do that here and define in you to do item. So each to do we'll have a navy let's say Here you go one then the second or another is the title. It's a good idea. If you do use a or a meter is done it is not done yet so it will first then last barometer updated. And here because it is a daytime time so we can use the variable date time. Now for example we can copy this say the same to do and we create another one. So when you say create it use create articles we can format this election. Now we want to show this list of to do's inside the user interface for that. Here I'll go to the main page that Zambal and from here instead of showing this simple label and going and deleted. And so instead of you give me a list of you name it's called to do list of you so that I can use it from the code behind an addition to this what they need to do also. Is to say artistic property has never rose to true. Because here I want to change the default layout of the view the default layout just shows one thing for each row. But here we have multiple multiple data to show inside that list. If you have an ID title is done and updated at. So how those different properties will be shown. I need to define a data template for each row in my list of view for that go here and say let's give you the item template. Then inside the item template define the data template that we need to define if used in inside views they. You want to use a stack layout and the stack layout here is that can show items one below the other. So here for the stack layout I want you to show the label the label will show the value text equal. And here I'm going to do it binding and binding means that they want this label to show a value of property called ID. We'll see later how we can pass this list to you. This to do is to our list of you so the media now that our list you have a list of to do's and don'ts to do. We'll be showing you right here so every views there or every data template every item of our list of you can access that to do. So the first one or the first labor rate you will access the property ID. The second one with X is a property title to show the title and the second row and the same thing to do with the other properties. So here it's going to be better than the second will be is done. Make sure you read the same values right here. The fourth property will be updated at. Now let's bind this list of you to this list of the way to do that. Come back here to main page determine that. Yes. And here just I called my to do list view I can get it to do list view. Then they call a property item source and stores equal my list of to do. So with this line of code I just tell my list to you to take this list of do's as it's items them. This resource will be visible from each item template so that here I can read the value of the title is done and updated at let's run this application. And here I see my mistake of you showing the three hour three to do items that you have created in code behind. So those are the items shown here and you see because you show them inside stack layout they are shown one below the other.