У меня есть проблема с привязкой, когда я инициализирую контекст с помощью оператора using
, Привязка к имени пациента будет пустой, если я использовал следующий код:
using (myEntities context = new myEntities ())
{
IQueryable<Appointment> query = context.Appointments.Where(s => s.AppointmentDate == _activeDate);
ocAppointments = new ObservableCollection<Appointment>(query);
lbShiftAppointments.ItemsSource = ocAppointments.Where(s => s.DoctorShift.ShiftNumber == 1);
}
Но если я инициализирую контекст без using
statment привязка работает:
myEntities context = new myEntities ();
IQueryable<Appointment> query= context.Appointments.Where(s => s.AppointmentDate == _activeDate);
ocAppointments = new ObservableCollection<Appointment>(query);
lbShiftAppointments.ItemsSource = ocAppointments.Where(s => s.DoctorShift.ShiftNumber == 1);
Это список
<ListBox x:Name="lbShiftAppointments" Style="{StaticResource GridBody}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<ToggleButton x:Name="tbtnShiftAppointment">
<StackPanel >
<TextBlock Text="{Binding patient.name}"/>
</StackPanel>
</ToggleButton>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Я в замешательстве, любая помощь
ОБНОВЛЕНИЕ Я загрузил небольшое приложение WPF со своей проблемой, вы можете скачать с ЗДЕСЬ