Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Xamls.cs
- using App3.Models;
- using App3.ViewModels;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- namespace App3
- {
- public partial class MainPage : ContentPage
- {
- public MainPage()
- {
- MainViewModel mainViewModel = new MainViewModel();
- BindingContext = mainViewModel.GetEmployeesList();
- InitializeComponent();
- }
- }
- }
- Xaml
- <?xml version="1.0" encoding="utf-8" ?>
- <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:local="clr-namespace:App3"
- x:Class="App3.MainPage"
- xmlns:ViewModels="clr-namespace:App3.ViewModels">
- <ListView ItemsSource="{Binding .}"
- HasUnevenRows="True">
- <ListView.ItemTemplate>
- <DataTemplate>
- <ViewCell>
- <StackLayout Orientation="Horizontal">
- <Label Text="{Binding Name}"/>
- <Label Text="{Binding Department}"/>
- </StackLayout>
- </ViewCell>
- </DataTemplate>
- </ListView.ItemTemplate>
- </ListView>
- </ContentPage>
- Model Employee
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace App3.Models
- {
- public class Employee
- {
- public int Id { get; set; }
- public string Name { get; set; }
- public string Department { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement