Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绑定到列表框的组合框数据不会显示显示成员_C#_.net_Sql_Wpf - Fatal编程技术网

C# 绑定到列表框的组合框数据不会显示显示成员

C# 绑定到列表框的组合框数据不会显示显示成员,c#,.net,sql,wpf,C#,.net,Sql,Wpf,我有一个组合框,用于填充数据库中的数据,该组合框基于列表框选择,通过SQL查询填充给定列表框中的数据。问题是显示成员属性不会显示。我不会显示后端sql,因为它可以正常工作,并且列表框实际上填充的只是显示成员。因此,列表框中的数据为空 代码如下: 组合框方法: private void populateFromMedication() { MedicationList medicationItem = new MedicationList(); // if item is sel

我有一个组合框,用于填充数据库中的数据,该组合框基于列表框选择,通过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 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更改?