Advertisement
Guest User

cs

a guest
Mar 30th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Runtime.InteropServices.WindowsRuntime;
  7. using Windows.Foundation;
  8. using Windows.Foundation.Collections;
  9. using Windows.UI.WindowManagement;
  10. using Windows.UI.Xaml;
  11. using Windows.UI.Xaml.Controls;
  12. using Windows.UI.Xaml.Controls.Primitives;
  13. using Windows.UI.Xaml.Data;
  14. using Windows.UI.Xaml.Hosting;
  15. using Windows.UI.Xaml.Input;
  16. using Windows.UI.Xaml.Media;
  17. using Windows.UI.Xaml.Media.Imaging;
  18. using Windows.UI.Xaml.Navigation;
  19.  
  20. namespace Nazwiska
  21. {
  22.     public sealed partial class MainPage : Page
  23.     {
  24.         ObservableCollection<Osoba> osoba = new ObservableCollection<Osoba>();
  25.         public MainPage()
  26.         {
  27.             this.InitializeComponent();
  28.             osoba.Add(new Osoba("Bartek", "Chwyć", "Biała Podlaska", "ms-appx:///Assets//Bartek.png"));
  29.             osoba.Add(new Osoba("Marian", "Marczuk", "Biała Podlaska", "ms-appx:///Assets//Marian.png"));
  30.             osoba.Add(new Osoba("Grześ", "Wojtiuk", "Miedzyrzec", "ms-appx:///Assets//grzes.png"));
  31.             ListBox.ItemsSource = osoba;
  32.         }
  33.         private void Dodaj_Click(object sender, RoutedEventArgs e)
  34.         {
  35.             osoba.Add(new Osoba(ImieTxt.Text, NazwiskoTxt.Text, AdresTxt.Text, "ms-appx:///Assets//Marian.png"));
  36.         }
  37.  
  38.         private void Usun_Click(object sender, RoutedEventArgs e)
  39.         {
  40.  
  41.             Osoba kill = (Osoba)ListBox.SelectedItem;
  42.             osoba.Remove(kill);
  43.         }
  44.  
  45.         private void Edytuj_Click(object sender, RoutedEventArgs e)
  46.         {
  47.             Osoba o = (Osoba)ListBox.SelectedItem;
  48.  
  49.             o.Imie = ImieTxt.Text;
  50.             o.Nazwisko = NazwiskoTxt.Text;
  51.             o.Adres = AdresTxt.Text;
  52.         }
  53.         private void Szczegoly_Click(object sender, RoutedEventArgs e)
  54.         {
  55.             ShowNewWindow(sender, e);
  56.         }
  57.         AppWindow appWindow;
  58.         Frame appWindowFrame = new Frame();
  59.         private async void ShowNewWindow(object sender, RoutedEventArgs e)
  60.         {
  61.             Osoba osos = (Osoba)ListBox.SelectedItem;
  62.  
  63.             appWindow = await AppWindow.TryCreateAsync();
  64.             appWindowFrame.Navigate(typeof(Form2),osos);
  65.             ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame);
  66.             appWindow.Closed += delegate
  67.             {
  68.                 appWindowFrame.Content = null;
  69.                 appWindow = null;
  70.             };
  71.             await appWindow.TryShowAsync();
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement