/// <summary>
 /// Сохранить машину
 /// </summary>
 /// <param name="obj">Не нужно</param>
 private void SaveCar(object obj)
 {
     SelectedCar.ID_Cliente = SelectedCarCustomer.ID;
     SelectedCar.EndEdit();
     IsEditing = false;
     if (!Cars.Contains(SelectedCar))
     {
         App.carDataService.NewCar(SelectedCar);
         Cars.Add(SelectedCar);
     }
 }
Exemple #2
0
        public void ShowSearchResult(SLTextBox txtTarget, Panel addTo, List <SLCar> searchList)
        {
            if (searchList == null || searchList.Count == 0 || txtTarget == null || addTo == null)
            {
                return;
            }

            Orientation         = Orientation.Vertical;
            Margin              = new Thickness(5, 30, 0, 0);
            VerticalAlignment   = VerticalAlignment.Top;
            HorizontalAlignment = HorizontalAlignment.Left;
            MaxHeight           = 400;
            Width = txtTarget.Width;
            SLListBox listBox = null;

            if (Children.Count == 0)
            {
                listBox                    = new SLListBox();
                listBox.Width              = Width;
                listBox.SelectionMode      = SelectionMode.Single;
                listBox.MouseLeftButtonUp += (sender, args) =>
                {
                    args.Handled = true;
                    Visibility   = Visibility.Collapsed;
                    if (listBox.SelectedItems.Count > 0)
                    {
                        SLCar selcar = (SLCar)listBox.SelectedItems[0];
                        SelectedCar?.Invoke(selcar);
                    }
                };
                Children.Add(listBox);
                txtTarget.MouseLeftButtonDown += (sender, e) =>
                {
                    Visibility = Visibility.Collapsed;
                    searchList.Clear();
                };
            }
            else
            {
                listBox = Children[0] as SLListBox;
            }

            listBox.ItemsSource = searchList;

            Grid.SetRowSpan(this, 3);

            if (!addTo.Children.Contains(this))
            {
                addTo.Children.Add(this);
            }

            Visibility = Visibility.Visible;
        }