Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin_Forms.Model;
- using Rg.Plugins.Popup.Pages;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace Xamarin_Forms.Views.Popup
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class ChoosePartsPopup : PopupPage
- {
- public ObservableCollection<PartDto> _parts { get; set; }
- public ChoosePartsPopup ()
- {
- InitializeComponent ();
- InitializeView();
- CloseWhenBackgroundIsClicked = true;
- // InitEvents();
- }
- //private void InitEvents()
- //{
- // // take the selected technician and call the method to create the new activity
- // lv_parts.ItemTapped += (object sender, ItemTappedEventArgs e) =>
- // {
- // DisplayAlert("Tapped", "Items Is Tapped", "ok");
- // OnBackButtonPressed();
- // };
- //}
- private void InitializeView()
- {
- _parts = new ObservableCollection<PartDto>()
- {
- new PartDto{ Code = "L6FT", Description = "China Cup", Quantity = "2"},
- new PartDto{ Code = "FIL20x50", Description = "China Plate", Quantity = "2"},
- new PartDto{ Code = "L4FT", Description = "China Glass", Quantity = "2"}
- };
- lv_parts.IsVisible = true;
- lv_parts.ItemsSource = _parts;
- }
- protected override Task OnAppearingAnimationEnd()
- {
- return Content.FadeTo(0.5);
- }
- // Method for animation child in PopupPage
- // Invoked before custom animation begin
- protected override Task OnDisappearingAnimationBegin()
- {
- return Content.FadeTo(1);
- }
- protected override void OnAppearing()
- {
- base.OnAppearing();
- }
- protected override void OnDisappearing()
- {
- base.OnDisappearing();
- }
- // ### Methods for supporting animations in your popup page ###
- // Invoked before an animation appearing
- // ### Overrided methods which can prevent closing a popup page ###
- // Invoked when a hardware back button is pressed
- protected override bool OnBackButtonPressed()
- {
- // Return true if you don't want to close this popup page when a back button is pressed
- return base.OnBackButtonPressed();
- }
- // Invoked when background is clicked
- protected override bool OnBackgroundClicked()
- {
- // Return false if you don't want to close this popup page when a background of the popup page is clicked
- return base.OnBackgroundClicked();
- }
- async void Lv_parts_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
- {
- if (lv_parts.SelectedItem == null)
- return;
- var selectedPart = e.SelectedItem as PartDto;
- // await Navigation.PushAsync(new woTabsParts(selectedPart));
- lv_parts.SelectedItem = null;
- var page = new woTabsParts(selectedPart);
- page.ContactUpdated += (source, part) =>
- {
- // When the target page raises ContactUpdated event, we get
- // notified and update properties of the selected contact.
- // Here we are dealing with a small class with only a few
- // properties. If working with a larger class, you may want
- // to look at AutoMapper, which is a convention-based mapping
- // tool.
- selectedPart.Code = part.Code;
- selectedPart.Description = part.Description;
- selectedPart.Quantity = part.Quantity;
- };
- await Navigation.PushAsync(page);
- OnBackgroundClicked();
- }
- }
- }
Add Comment
Please, Sign In to add comment