示例#1
0
        public AdopterAdd()
        {
            InitializeComponent();
            var adressesFromDB = viewModelAdopter.GetAdresses();

            this.addresses = new ObservableCollection <Adress>(adressesFromDB);
            this.addressesWithoutFilter = new ObservableCollection <Adress>(addresses);
            DataGridCity.ItemsSource    = addresses;
        }
        public AdopterEdit(AdopterWithAdress adopterToEdit, ObservableCollection <AdopterWithAdress> adoptersWithAdress)
        {
            this.adopterToEdit      = adopterToEdit;
            this.adoptersWithAdress = adoptersWithAdress;
            var getAdresses = new ObservableCollection <Adress>(viewmodel.GetAdresses());

            this.addresses = getAdresses;
            this.addressesWithoutFilter = new ObservableCollection <Adress>(addresses);
            InitializeComponent();

            TextBoxName.Text        = adopterToEdit.Name;
            TextBoxSurname.Text     = adopterToEdit.Surname;
            TextBoxPhone.Text       = adopterToEdit.PhoneNumber;
            TextBoxStreet.Text      = adopterToEdit.Street;
            TextBoxHouseNumber.Text = adopterToEdit.HouseNumber;

            DataGridCity.ItemsSource  = viewmodel.GetAdresses();
            DataGridCity.SelectedItem = viewmodel.GetAdressById(adopterToEdit.IdAdress);
            DataGridCity.ScrollIntoView(DataGridCity.Items[DataGridCity.Items.Count - 1]);
            DataGridCity.ScrollIntoView(DataGridCity.SelectedItem);
        }