我試圖明確定義datagrid列時不斷收到此錯誤。如果我註釋掉3個datagridtext列,它可以工作(但我想隱藏一些列)。在我的代碼中,我所做的只是爲DataGridLookupsTab設置datacontext ..而不是搞亂itemsource或代碼中的任何東西。任何想法,我可能在這裏做錯了嗎?項目集合必須爲空之前使用itemssource - datagrid wpf
謝謝!
<TabItem Header="Lookups" Height="23" VerticalAlignment="Top">
<Grid x:Name="DataGridLookupsTab" Background="#FFE5E5E5" Margin="0,0,-1,-2" DataContext="Apps.OMS.Models.Lookups">
<ComboBox x:Name="ComboBoxDistinctLookups" HorizontalAlignment="Left" Margin="128,14,0,0" VerticalAlignment="Top" Width="228" ItemsSource="{Binding Path=LookupTypeList}" SelectionChanged="ComboBoxDistinctLookups_SelectionChanged"/>
<Label Content="Select Lookup Type" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" RenderTransformOrigin="1.105,4.731"/>
<DataGrid x:Name="DataGridLookups" HorizontalAlignment="Left" Margin="10,41,0,0" VerticalAlignment="Top" Width="768" Height="327" ItemsSource="{Binding LookupRecords}" >
<DataGridTextColumn Binding="{Binding LookupType}" Header="Lookup Type" />
<DataGridTextColumn Binding="{Binding LookupValue}" Header="Lookup Value" />
<DataGridTextColumn Binding="{Binding LookupDescription}" Header="Lookup Description" />
</DataGrid>
</Grid>
</TabItem>
可能重複的[DataGridTemplateColumn:項目集合必須爲空之前使用ItemsSource。](http://stackoverflow.com/questions/6882306/datagridtemplatecolumn-items-collection-must-be-empty-before-using-的ItemsSource) – 2015-12-08 14:38:00