我觉得我错过了一些非常明显的东西,但是我无法使用基本的绑定来处理我的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();
}
}