如何将实体对象绑定到WPF TextBox?

时间:2010-08-18 13:50:57

标签: entity-framework xaml textbox binding

我觉得我错过了一些非常明显的东西,但是我无法使用基本的绑定来处理我的EDM中的对象。

这是我的xaml:

    <TextBox Text="{Binding Path=receipt.STATUS}"  Height="23" HorizontalAlignment="Left" Margin="371,276,0,0" VerticalAlignment="Top" Width="120" />

这是我的View代码隐藏:

public MainWindow()
{
    InitializeComponent();
    _vw = new SimpleViewModel();
    DataContext = _vw;
}

这是我的ViewModel:

class SimpleViewModel
{
    private MyEntities _context;
    public RECEIPT receipt;
    ...
    public void GetReceipt(receiptKey)
    {
        IQueryable<RECEIPT> r = from it in _context.RECEIPTs
                                      where it.RECEIPTKEY == receiptKey
                                      select it;
        receipt = r.First();
    }
}

0 个答案:

没有答案