我的组合框返回不正确的文本值

时间:2013-07-27 06:01:48

标签: c# wpf entity-framework

 public void DD_Location()
    {
        var ctx = new LCCDB_EF();
        var query = ctx.tbl_Location;
        CB_Location.DataContext = query.ToList();
    }

    private void CB_Location_DropDownClosed(object sender, EventArgs e)
    {           
       textbox_test.Text =CB_Location.Text;
    }

文本框中的输出

  

System.Data.Entity.DynamicProxies.Location_5E43C6C196972BF0754973E48C9C941092D86818CD94005E9A759B70BF6E48E6

2 个答案:

答案 0 :(得分:0)

试试这个

if(null != CB_Location.SelectedItem)
    textbox_test.Text = CB_Location.SelectedItem.ToString();

答案 1 :(得分:0)

如果没有看到您的XAML,我无法确定,但您确定已正确绑定列表吗?尝试将combobox的Items属性设置为列表,而不是数据上下文。根据类型的类型以及您要将文本绑定到的内容,您可能还需要根据需要设置DisplayMemberPath属性。

相关问题