Hello,I have a WPF app and I want to know what is the problem with my binding.I have a combobox that holds some values,and when I put the breakpoint where the function for the combobox is,after I put the breakpoint and I want to debug,I won't enter the applciation,instead,when I'm about to go into the application it breaks.That's not normal since it should break when I select the value in the combobox,so it should enter the application and I should be able to see all the functionalities of the Window.What could be the problem that causes this?
This is my method for the combobox:
public IEnumerable<AvailableCours> GetByEducation()
{
using (var context = new AttendanceStudentsEntities())
{
var query = (from data in context.AvailableCourses select new { Education = data.education }).ToList().Select(c => new AvailableCours { education = c.Education }).ToList();
return query.ToList();
}
}
This is the binding in the view:
<ComboBox HorizontalAlignment="Left" Margin="166,229,0,0" Grid.Row="2" DisplayMemberPath="education" VerticalAlignment="Top" Name="cbxCourses" ItemsSource="{Binding Education}" SelectedItem="{Binding Path=Education}" IsSynchronizedWithCurrentItem="True" Width="264" Grid.RowSpan="2"/>
If something else would be relevant to understand the problem,please tell me and I'll post it.I also get binding errors such as:
System.Windows.Data Information: 41 : BindingExpression path error: 'education' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=education; DataItem=null; target element is 'ComboBox' (Name='cbxCourses'); target property is 'NoTarget' (type 'Object')
System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=education; DataItem=null; target element is 'ComboBox' (Name='cbxCourses'); target property is 'NoTarget' (type 'Object')
System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=education; DataItem=null; target element is 'ComboBox' (Name='cbxCourses'); target property is 'NoTarget' (type 'Object')
System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=education; DataItem=null; target element is 'ComboBox' (Name='cbxCourses'); target property is 'NoTarget' (type 'Object')
What I have tried:
I have tried to make the view again,I redone the db,I changed the method of the GetEducation() so that the Courses list would add the value of the items(courses),still didn't work.I would really appreciate an advice.