Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- using CRUD.Models;
- using Xamarin.Forms;
- using SQLite;
- using Xamarin.Forms.Xaml;
- using System.Linq;
- namespace CRUD.Views
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class GetAllCompaniesPage : ContentPage
- {
- string _dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "myDB.db3");
- private ListView _listView;
- private Company _company;
- private object _idEntry;
- private object _nameEntry;
- private object _addressEntry;
- public GetAllCompaniesPage()
- {
- this.Title = "Companies";
- var db = new SQLiteConnection(_dbPath);
- StackLayout stackLayout = new StackLayout();
- _listView = new ListView();
- _listView.ItemsSource = db.Table<Company>().OrderBy(x => x.Name).ToList();
- _listView.ItemSelected += _listView_ItemSelected;
- stackLayout.Children.Add(_listView);
- Content = stackLayout;
- }
- private void _listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
- {
- _company = (Company)e.SelectedItem;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement