1
我有一個組合框來填充數據庫中的數據,它基於列表框選擇通過SQL查詢填充給定列表框中的數據。問題是顯示成員屬性不會顯示。我不會顯示後端SQL,因爲這可以正常工作,並且列表框實際上只填充顯示成員。所以列表框中的數據是空白的。綁定到列表框的組合框數據將不會顯示顯示成員
下面是代碼:
組合框的方法:
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 FormInitialize()
{
InitializeComponent();
LoadData();
LoadResidentData();
populateFromMedication();
}
MedicationList類:
public class MedicationList
{
public int MedicationID { get; set; }
public string Description
{
get
{
return Description;
}
set
{
Description = value;
OnPropertyChanged("Description");
}
}
}
你能解釋一下你的第一點嗎?非常清楚。謝謝 – Mark
@Mark:在你的類中,MedicationList有一個名爲'Description'的屬性? –
我該如何去改變onPropertyChanged? – Mark