2

サンプル プロジェクトを作成していますが、コードに問題があります。

...
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 とは

誰かがこの問題を解決するのを手伝ってくれることを願っています。ありがとうございました。

4

2 に答える 2

-1

名前空間が正しいと仮定すると、インポートする適切な方法は次のとおりです。

xmlns:data="clr-namespace:OrnekUygulama.Model"
于 2016-03-31T14:35:10.573 に答える