Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. Xamls.cs
  2. using App3.Models;
  3. using App3.ViewModels;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Xamarin.Forms;
  10.  
  11. namespace App3
  12. {
  13. public partial class MainPage : ContentPage
  14. {
  15. public MainPage()
  16. {
  17. MainViewModel mainViewModel = new MainViewModel();
  18.  
  19. BindingContext = mainViewModel.GetEmployeesList();
  20.  
  21. InitializeComponent();
  22. }
  23. }
  24. }
  25.  
  26. Xaml
  27.  
  28. <?xml version="1.0" encoding="utf-8" ?>
  29. <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
  30. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  31. xmlns:local="clr-namespace:App3"
  32. x:Class="App3.MainPage"
  33. xmlns:ViewModels="clr-namespace:App3.ViewModels">
  34.  
  35.  
  36. <ListView ItemsSource="{Binding .}"
  37. HasUnevenRows="True">
  38.  
  39.  
  40. <ListView.ItemTemplate>
  41. <DataTemplate>
  42. <ViewCell>
  43. <StackLayout Orientation="Horizontal">
  44. <Label Text="{Binding Name}"/>
  45. <Label Text="{Binding Department}"/>
  46. </StackLayout>
  47. </ViewCell>
  48. </DataTemplate>
  49. </ListView.ItemTemplate>
  50. </ListView>
  51.  
  52. </ContentPage>
  53.  
  54.  
  55. Model Employee
  56.  
  57. using System;
  58. using System.Collections.Generic;
  59. using System.Linq;
  60. using System.Text;
  61. using System.Threading.Tasks;
  62.  
  63. namespace App3.Models
  64. {
  65. public class Employee
  66. {
  67. public int Id { get; set; }
  68.  
  69. public string Name { get; set; }
  70.  
  71. public string Department { get; set; }
  72.  
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement