Получаю Null в комбо боксах

Мне нужна помощь. У меня есть таблица с комбобоксом, которая прекрасно работает, и выглядит она так:

 private Workers _currentWorkers = new Workers();
        public WorkersEditAdd(Workers selectWorkers)
        {
            InitializeComponent();

            if(selectWorkers != null)
                _currentWorkers= selectWorkers;
            DataContext = _currentWorkers;
            ComboFunctions.ItemsSource = Toy_StoreEntities1.GetContext().Functions.ToList();
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentWorkers.First_name))
                errors.AppendLine("Please enter First name");
            if (string.IsNullOrWhiteSpace(_currentWorkers.Last_name))
                errors.AppendLine("Please enter Last name");
            if (string.IsNullOrWhiteSpace(_currentWorkers.Third_name))
                errors.AppendLine("Please enter Third name");
            if (_currentWorkers.Salary < 0)
                errors.AppendLine("Please enter a number of Salary more than 0");
            if (_currentWorkers.Key <= 0)
                errors.AppendLine("Please enter a number of Key more than 0");
            if (_currentWorkers.Functions == null)
                errors.AppendLine("Choose a function");

            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }

строка комбо бокса оформлена так:

<ComboBox SelectedItem="{Binding Functions}" Grid.Column="1" Margin="20,10,8,10" x:Name="ComboFunctions" DisplayMemberPath="Function" Grid.Row="4"></ComboBox>

Но когда я начал оформлять комбобоксы в другой таблице таким образом:

public SellsEditAdd(Sells selectSells)
        {
            InitializeComponent();

            if (selectSells != null)
                _currentSells = selectSells;
            DataContext = _currentSells;
            ComboToys.ItemsSource = Toy_StoreEntities1.GetContext().Toys.ToList();
            ComboForms.ItemsSource = Toy_StoreEntities1.GetContext().Forms.ToList();
            ComboCountries.ItemsSource = Toy_StoreEntities1.GetContext().Countries.ToList();
            ComboFirms.ItemsSource = Toy_StoreEntities1.GetContext().Firms.ToList();
            ComboWorkers.ItemsSource = Toy_StoreEntities1.GetContext().Workers.ToList();
            ComboClients.ItemsSource = Toy_StoreEntities1.GetContext().Clients.ToList();

        }

Мне выдает список, что надо заполнить эти комбобоксы, ибо они пустые.

Их строчки оформлены так:

<ComboBox SelectedItem="{Binding Toy}" Grid.Column="1" Margin="20,10,8,10" x:Name="ComboToys" DisplayMemberPath="Toy" Grid.Row="1"></ComboBox>
        <ComboBox SelectedItem="{Binding Form}" Grid.Column="1" Margin="20,10,8,10" x:Name="ComboForms" DisplayMemberPath="Form" Grid.Row="2"></ComboBox>
        <ComboBox SelectedItem="{Binding Country}" Grid.Column="1" Margin="20,10,8,10" x:Name="ComboCountries" DisplayMemberPath="Country" Grid.Row="4"></ComboBox>
        <ComboBox SelectedItem="{Binding Firm}" Grid.Column="1" Margin="20,10,8,10" x:Name="ComboFirms" DisplayMemberPath="Firm" Grid.Row="5"></ComboBox>

        <ComboBox SelectedItem="{Binding Worker}" Grid.Column="1" Margin="20,10,8,10" x:Name="ComboWorkers" DisplayMemberPath="First_name" Grid.Row="8"></ComboBox>
        <ComboBox SelectedItem="{Binding Client}" Grid.Column="1" Margin="20,10,8,10" x:Name="ComboClients" DisplayMemberPath="First_name" Grid.Row="9"></ComboBox>

Причем я спокойно могу выбирать предметы из списка, но они подчеркиваются красным как пустые Нулевые комбобоксы что я делаю не так можете подсказать?


Ответы (0 шт):