Guest User

Untitled

a guest
Mar 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Xamarin_Forms.Model;
  8. using Rg.Plugins.Popup.Pages;
  9.  
  10. using Xamarin.Forms;
  11. using Xamarin.Forms.Xaml;
  12.  
  13. namespace Xamarin_Forms.Views.Popup
  14. {
  15. [XamlCompilation(XamlCompilationOptions.Compile)]
  16. public partial class ChoosePartsPopup : PopupPage
  17. {
  18. public ObservableCollection<PartDto> _parts { get; set; }
  19.  
  20. public ChoosePartsPopup ()
  21. {
  22. InitializeComponent ();
  23. InitializeView();
  24. CloseWhenBackgroundIsClicked = true;
  25. // InitEvents();
  26.  
  27. }
  28.  
  29. //private void InitEvents()
  30. //{
  31. // // take the selected technician and call the method to create the new activity
  32. // lv_parts.ItemTapped += (object sender, ItemTappedEventArgs e) =>
  33. // {
  34. // DisplayAlert("Tapped", "Items Is Tapped", "ok");
  35. // OnBackButtonPressed();
  36. // };
  37. //}
  38.  
  39. private void InitializeView()
  40. {
  41. _parts = new ObservableCollection<PartDto>()
  42. {
  43. new PartDto{ Code = "L6FT", Description = "China Cup", Quantity = "2"},
  44. new PartDto{ Code = "FIL20x50", Description = "China Plate", Quantity = "2"},
  45. new PartDto{ Code = "L4FT", Description = "China Glass", Quantity = "2"}
  46. };
  47. lv_parts.IsVisible = true;
  48. lv_parts.ItemsSource = _parts;
  49. }
  50.  
  51.  
  52. protected override Task OnAppearingAnimationEnd()
  53. {
  54. return Content.FadeTo(0.5);
  55. }
  56.  
  57. // Method for animation child in PopupPage
  58. // Invoked before custom animation begin
  59. protected override Task OnDisappearingAnimationBegin()
  60. {
  61. return Content.FadeTo(1);
  62. }
  63.  
  64.  
  65.  
  66. protected override void OnAppearing()
  67. {
  68. base.OnAppearing();
  69. }
  70.  
  71. protected override void OnDisappearing()
  72. {
  73. base.OnDisappearing();
  74. }
  75.  
  76. // ### Methods for supporting animations in your popup page ###
  77.  
  78. // Invoked before an animation appearing
  79.  
  80.  
  81. // ### Overrided methods which can prevent closing a popup page ###
  82.  
  83. // Invoked when a hardware back button is pressed
  84. protected override bool OnBackButtonPressed()
  85. {
  86. // Return true if you don't want to close this popup page when a back button is pressed
  87. return base.OnBackButtonPressed();
  88. }
  89.  
  90. // Invoked when background is clicked
  91. protected override bool OnBackgroundClicked()
  92. {
  93. // Return false if you don't want to close this popup page when a background of the popup page is clicked
  94. return base.OnBackgroundClicked();
  95. }
  96.  
  97. async void Lv_parts_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
  98. {
  99. if (lv_parts.SelectedItem == null)
  100. return;
  101.  
  102. var selectedPart = e.SelectedItem as PartDto;
  103. // await Navigation.PushAsync(new woTabsParts(selectedPart));
  104. lv_parts.SelectedItem = null;
  105.  
  106.  
  107. var page = new woTabsParts(selectedPart);
  108. page.ContactUpdated += (source, part) =>
  109. {
  110. // When the target page raises ContactUpdated event, we get
  111. // notified and update properties of the selected contact.
  112. // Here we are dealing with a small class with only a few
  113. // properties. If working with a larger class, you may want
  114. // to look at AutoMapper, which is a convention-based mapping
  115. // tool.
  116. selectedPart.Code = part.Code;
  117. selectedPart.Description = part.Description;
  118. selectedPart.Quantity = part.Quantity;
  119. };
  120.  
  121. await Navigation.PushAsync(page);
  122. OnBackgroundClicked();
  123. }
  124. }
  125. }
Add Comment
Please, Sign In to add comment