Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
InfoBlog/InfoBlog/Views/BlogPage.xaml.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (42 sloc)
1.29 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using InfoBlog.Models; | |
using InfoBlog.ViewModel; | |
using SQLite; | |
using Xamarin.Forms; | |
namespace InfoBlog.Views | |
{ | |
public partial class BlogPage : ContentPage | |
{ | |
public BlogPage() | |
{ | |
InitializeComponent(); | |
BindingContext = new BlogPostViewModel(); | |
} | |
private async void OnPostSelected(object sender, ItemTappedEventArgs e) | |
{ | |
var Blogdetails = e.Item as PostForm; | |
await Navigation.PushAsync(new BlogPageDetail(Blogdetails.Topic, Blogdetails.Image, Blogdetails.Contents, Blogdetails.User)); | |
} | |
void AddBlog(object sender, System.EventArgs e) | |
{ | |
Navigation.PushAsync(new AddBlog()); | |
} | |
void Logout(object sender, System.EventArgs e) | |
{ | |
Navigation.PushAsync(new WelcomePage()); | |
} | |
//Get data from the database | |
protected override void OnAppearing() | |
{ | |
base.OnAppearing(); | |
using (SQLiteConnection conn = new SQLiteConnection(App.Filepath)) | |
{ | |
conn.CreateTable<PostForm>(); | |
var posts = conn.Table<PostForm>().ToList(); | |
blogList.ItemsSource = posts; | |
} | |
} | |
} | |
} |