2010-02-23 69 views
1

我使用下面的代碼來填充項的WPF數據網格中的db4o我OODB:WPF DataGrid的問題與DB40

IObjectContainer DB = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(),「C:\開發\ ContractKeeper \數據庫\ ContractKeeper.yap「);

var contractTypes = db.Query(typeof(ContractType));

this.dataGrid1.ItemsSource = contractTypes.ToList();

這裏是XAML:

<Window x:Class="ContractKeeper.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" 
    Title="Window1" Height="300" Width="300"> 
    <Grid> 
     <dg:DataGrid AutoGenerateColumns="True" Margin="12,102,12,24" Name="dataGrid1" /> 
    </Grid> 
</Window> 

當項目將綁定到DataGrid,網格線出現像有記錄,但不顯示任何數據。有沒有人有與db4o和wpf datagrid這個問題?

+0

XAML代碼丟失。你可以添加它嗎? – Gamlor 2010-02-23 20:32:05

+0

我在我的文章中包含了XAML代碼。但是,StackOverflow如何將它發佈回來,XAML不會顯示。我不知道爲什麼,有趣。 – 2010-02-25 02:15:09

+0

您是否將XAML標記爲代碼?並且你是否從ToList獲得結果(例如,調試它或將其打印到標準輸出) – Karussell 2010-02-26 11:53:55

回答

1

我解決了我的問題。但是,我並不完全明白髮生了什麼事情。如果我弄明白了,我會更新這篇文章。