public FootballPlayerListPage() { this.BindingContext = new FootballPlayerViewModel (); Title = "Football Legends"; var create = new ToolbarItem (); create.Name = "create"; this.ToolbarItems.Add (create); create.Clicked += Create_Clicked; // create.SetBinding (ToolbarItem.CommandProperty, "CreatePlayer"); MyFootballList = new ListView (); MyFootballList.IsPullToRefreshEnabled = true; MyFootballList.Refreshing += MyFootballList_Refreshing; MyFootballList.SetBinding (ListView.ItemsSourceProperty, "Footballplayercollection"); var cell = new DataTemplate (typeof(FootballPlayerListCell)); MyFootballList.ItemTemplate = cell; MyFootballList.RowHeight = 70; MessagingCenter.Subscribe<FootballPlayerListCell>(this,"delete",(sender) => { this.BindingContext = new FootballPlayerViewModel(); FootballPlayer dat= new FootballPlayer (); MyFootballList.ItemsSource = dat.GetItems (); },null); MyFootballList.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => { Navigation.PushAsync(new FootballPlayerDetailPage(e.SelectedItem)); }; this.Content = MyFootballList; }
protected override void OnAppearing() { base.OnAppearing(); FootballPlayer dat = new FootballPlayer(); MyFootballList.ItemsSource = dat.GetItems(); }
void MyFootballList_Refreshing(object sender, EventArgs e) { FootballPlayer dat = new FootballPlayer(); MyFootballList.ItemsSource = dat.GetItems(); MyFootballList.EndRefresh(); }
// public string _countryImage void OnSaveCommand() { string c; if (Country == 0) { c = "India"; } else if (Country == 1) { c = "USA"; } else if (Country == 2) { c = "Japan"; } else if (Country == 3) { c = "UK"; } else if (Country == 4) { c = "Australia"; } else { c = "Unavailable"; } player = new FootballPlayer(_FirstName, _LastName, _DOB, _DESC, c); player.saveFootBallPlayerData(player); }
void DeleteAction_Clicked(object sender, EventArgs e) { var x1 = (MenuItem)sender; var x2 = x1.BindingContext; FootballPlayer x3 = (FootballPlayer)x2; x3.deletePlayer(x3.ID); MessagingCenter.Send(this, "delete"); }
public FootballPlayerViewModel() { SaveCommand = new Command (OnSaveCommand); //CreatePlayer = new Command (OnCreatePlayerCommand); DeleteData = new Command (OnDeletePlayerCommand); //PickImage = new Command (onPick); player = new FootballPlayer (); Footballplayercollection =new ObservableCollection<FootballPlayer>(player.GetItems()); }
public FootballPlayerViewModel() { SaveCommand = new Command(OnSaveCommand); //CreatePlayer = new Command (OnCreatePlayerCommand); DeleteData = new Command(OnDeletePlayerCommand); //PickImage = new Command (onPick); player = new FootballPlayer(); Footballplayercollection = new ObservableCollection <FootballPlayer>(player.GetItems()); }
public FootballPlayerDetailPage(object obj) { InitializeComponent(); //this.BindingContext = obj; FootballPlayer myObj = (FootballPlayer)obj; this.FirstNameDetail.Text = myObj.PFName; this.LastNameDetail.Text = myObj.PLName; this.DOBDetail.Text = myObj.PDOB.ToString(); this.DescriptionDetail.Text = myObj.PDesc; this.CountryDetail.Text = myObj.Pcountry; }
void Favourites_Clicked(object sender, EventArgs e) { MenuItem button = (MenuItem)sender; var x1 = (MenuItem)sender; var x2 = x1.BindingContext; FootballPlayer x3 = (FootballPlayer)x2; x3.fav = !x3.fav; if (x3.fav) { button.Text = "Un Favourite"; } else { button.Text = "Mark Favourite"; } x3.updateplayerFavourite(x3); }
public FootballPlayerListPage() { this.BindingContext = new FootballPlayerViewModel(); Title = "Football Legends"; var create = new ToolbarItem(); create.Name = "create"; this.ToolbarItems.Add(create); create.Clicked += Create_Clicked; // create.SetBinding (ToolbarItem.CommandProperty, "CreatePlayer"); MyFootballList = new ListView(); MyFootballList.IsPullToRefreshEnabled = true; MyFootballList.Refreshing += MyFootballList_Refreshing; MyFootballList.SetBinding(ListView.ItemsSourceProperty, "Footballplayercollection"); var cell = new DataTemplate(typeof(FootballPlayerListCell)); MyFootballList.ItemTemplate = cell; MyFootballList.RowHeight = 70; MessagingCenter.Subscribe <FootballPlayerListCell>(this, "delete", (sender) => { this.BindingContext = new FootballPlayerViewModel(); FootballPlayer dat = new FootballPlayer(); MyFootballList.ItemsSource = dat.GetItems(); }, null); MyFootballList.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => { Navigation.PushAsync(new FootballPlayerDetailPage(e.SelectedItem)); }; this.Content = MyFootballList; }
public FootballPlayerListCell() { FootballPlayer footballplayercollection = (FootballPlayer)this.BindingContext; var deleteAction = new MenuItem { Text = "", IsDestructive = true }; deleteAction.Clicked += DeleteAction_Clicked; this.ContextActions.Add (deleteAction); deleteAction.Text = "Delete"; var Favourites = new MenuItem { IsDestructive = false }; Favourites.Clicked += Favourites_Clicked; FootballPlayer foot = new FootballPlayer (); if (foot.fav) { Favourites.Text = "UnFavourite"; } else { Favourites.Text = "Mark Favourite"; } this.ContextActions.Add (Favourites); nameLabel = new Label () { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, WidthRequest = 100 }; var DOB = new Label () { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, WidthRequest = 100 }; var ageLabel = new Label () { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, Text = "age", WidthRequest = 100 }; var countryimg = new Image (); countryimg.SetBinding (Image.SourceProperty, "countryImage"); countryimg.GetSizeRequest (15, 15); var Lname = new Label () { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, WidthRequest = 100 }; nameLabel.SetBinding(Label.TextProperty,"PFName"); DOB.SetBinding (Label.TextProperty, "PlayerAge"); Lname.SetBinding (Label.TextProperty, "PLName"); var cellLayout = new StackLayout { Spacing = 5, Padding = new Thickness (5, 5, 5, 5), Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { nameLabel, Lname , new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 5, Children = { ageLabel, DOB } }, countryimg } }; this.View = cellLayout; }
public void saveFootBallPlayerData(FootballPlayer obj) { database.Insert(obj); }
public void updateplayerFavourite(FootballPlayer obj) { database.Update(obj); }
void MyFootballList_Refreshing(object sender, EventArgs e) { FootballPlayer dat= new FootballPlayer (); MyFootballList.ItemsSource = dat.GetItems (); MyFootballList.EndRefresh(); }
protected override void OnAppearing() { base.OnAppearing (); FootballPlayer dat= new FootballPlayer (); MyFootballList.ItemsSource = dat.GetItems (); }
public void saveFootBallPlayerData(FootballPlayer obj) { database.Insert (obj); }
public void updateplayerFavourite(FootballPlayer obj) { database.Update (obj); }
public FootballPlayerListCell() { FootballPlayer footballplayercollection = (FootballPlayer)this.BindingContext; var deleteAction = new MenuItem { Text = "", IsDestructive = true }; deleteAction.Clicked += DeleteAction_Clicked; this.ContextActions.Add(deleteAction); deleteAction.Text = "Delete"; var Favourites = new MenuItem { IsDestructive = false }; Favourites.Clicked += Favourites_Clicked; FootballPlayer foot = new FootballPlayer(); if (foot.fav) { Favourites.Text = "UnFavourite"; } else { Favourites.Text = "Mark Favourite"; } this.ContextActions.Add(Favourites); nameLabel = new Label() { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, WidthRequest = 100 }; var DOB = new Label() { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, WidthRequest = 100 }; var ageLabel = new Label() { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, Text = "age", WidthRequest = 100 }; var countryimg = new Image(); countryimg.SetBinding(Image.SourceProperty, "countryImage"); countryimg.GetSizeRequest(15, 15); var Lname = new Label() { FontFamily = "HelveticaNeue-Medium", FontSize = 18, TextColor = Color.Black, WidthRequest = 100 }; nameLabel.SetBinding(Label.TextProperty, "PFName"); DOB.SetBinding(Label.TextProperty, "PlayerAge"); Lname.SetBinding(Label.TextProperty, "PLName"); var cellLayout = new StackLayout { Spacing = 5, Padding = new Thickness(5, 5, 5, 5), Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { nameLabel, Lname, new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 5, Children = { ageLabel, DOB } }, countryimg } }; this.View = cellLayout; }
// public string _countryImage void OnSaveCommand() { string c; if (Country == 0) { c = "India"; } else if (Country == 1) { c = "USA"; } else if (Country == 2) { c = "Japan"; } else if (Country == 3) { c = "UK"; } else if (Country == 4) { c = "Australia"; } else { c = "Unavailable"; } player= new FootballPlayer (_FirstName,_LastName,_DOB,_DESC,c); player.saveFootBallPlayerData (player); }