0
爲什麼這個顯示數據:列表框不顯示數據
<ItemsControl ItemsSource="{Binding Path=.}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock FontWeight="Bold" Text="{Binding Category}" />
<TextBlock Text=", " />
<TextBlock Text="{Binding Title}" />
<TextBlock Text=" " />
<Label Content="{Binding ImageUrl}" Foreground="Blue" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
和下面顯示空行(但一樣多dataitems):
<ListBox ItemsSource="{Binding Path=.}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock FontWeight="Bold" Text="{Binding Category}" />
<TextBlock Text=", " />
<TextBlock Text="{Binding Title}" />
<TextBlock Text=" " />
<Label Content="{Binding ImageUrl}" Foreground="Blue" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
是否需要顯式設置'DataTemplate DataType'? – 2012-02-07 17:05:30