我正在编写一个示例项目,但我的代码如下所示。
...
xmlns:data="using:OrnekUygulama.Model"
...
<GridView Name="NewsArea"
Background="LightGray"
ItemsSource="{x:Bind NewsCollection}"
HorizontalAlignment="Stretch"
Margin="10,0,0,0">
<GridView.ItemTemplate>
<DataTemplate x:DataType="data:NewsCollection">
<Grid Background="White" Margin="10" Height="275" Width="200">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Image Name="NewsImages" Source="{x:Bind Image}" />
<RelativePanel Grid.Row="1">
<TextBlock Text="{x:Bind Headline}" />
<TextBlock Text="{x:Bind Subhead}" />
<TextBlock Text="{x:Bind DateLine}" />
</RelativePanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
这是我的 mainpage.xaml,我有错误 x:DataType="data:NewsCollection" 说无法解析 DataType data:NewsCollection但我在这里有:
public class NewsCollection
{
public int ID { get; set; }
public string Category { get; set; }
public string Headline { get; set; }
public string Subhead { get; set; }
public string DateLine { get; set; }
public string Image { get; set; }
}
哪个是 NewsCollection.cs
我希望有人可以帮助我解决这个问题。谢谢你。