C# 绑定到列表框的组合框数据不会显示显示成员
我有一个组合框,用于填充数据库中的数据,该组合框基于列表框选择,通过SQL查询填充给定列表框中的数据。问题是显示成员属性不会显示。我不会显示后端sql,因为它可以正常工作,并且列表框实际上填充的只是显示成员。因此,列表框中的数据为空 代码如下: 组合框方法:C# 绑定到列表框的组合框数据不会显示显示成员,c#,.net,sql,wpf,C#,.net,Sql,Wpf,我有一个组合框,用于填充数据库中的数据,该组合框基于列表框选择,通过SQL查询填充给定列表框中的数据。问题是显示成员属性不会显示。我不会显示后端sql,因为它可以正常工作,并且列表框实际上填充的只是显示成员。因此,列表框中的数据为空 代码如下: 组合框方法: private void populateFromMedication() { MedicationList medicationItem = new MedicationList(); // if item is sel
private void populateFromMedication()
{
MedicationList medicationItem = new MedicationList();
// if item is selected
if( !( ( Locations )cmbLocationDescriptionList.SelectedItem == null ) )
{
// set location to be the seletect location from the combo
location = ( Locations )cmbLocationDescriptionList.SelectedItem;
List<MedicationList> fromMedicatitionList = new List<MedicationList>();
// retrieve a list of medication from the database
fromMedicatitionList = LocationData.RetrieveMedicationByLocation( location.LocationID, GlobalVariables.SelectedResident.ResidentID );
//bind the list for to the medication list
lstMedicationForCurrentLocation.ItemsSource = fromMedicatitionList;
lstMedicationForCurrentLocation.DisplayMemberPath = "Description";
}
}
药物列表类别:
public class MedicationList
{
public int MedicationID { get; set; }
public string Description
{
get
{
return Description;
}
set
{
Description = value;
OnPropertyChanged( "Description" );
}
}
}
你需要检查一下 1)
MedicalationList
中有一个名为Description
的属性,OnPropertyChanged
应用于其setter
string _Description;
public string Description
{
get
{
return _Description;
}
set
{
_Description = value;
OnPropertyChanged("Description");
}
}
有关OnPropertyChanged的更多信息,请阅读
2) 在提供
Itemsource
之前,请尝试提供Displaymember
,您需要检查
1) MedicalationList
中有一个名为Description
的属性,OnPropertyChanged
应用于其setter
string _Description;
public string Description
{
get
{
return _Description;
}
set
{
_Description = value;
OnPropertyChanged("Description");
}
}
有关OnPropertyChanged的更多信息,请阅读
2) 在提供
Itemsource之前,请尝试提供Displaymember
。@马克:在您的类药物列表中是否有名为Description
的属性?如何更改onPropertyChanged?此上下文中不存在On属性更改?@马克:在您的类药物列表中是否有名为的属性说明
?如何更改onPropertyChanged?在此上下文中不存在OnProperty更改?