2016-03-31 22 views
1

Örnek bir proje yazıyorum ve kodumun altında bir sorun yaşıyorum.DataType XAML C çözülemiyor C#

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

Bu benim mainpage.xaml ve ben hata x vardır: VeriTürü = "veriler: NewsCollection" VeriTürü verilerini çözemez diyor ki: NewsCollection Ama var burada belirtin:

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; } 
} 

Hangi bir kişi bu sorunu çözmek için bana yardımcı olabilir umuyoruz. Teşekkür ederim. Size varsayarsak

cevap

0

O Visual Studio bir hata olduğunu 2015 sadece kod kısmını açıklama ve çalıştırın çözmek için. Bu uncomment sonra ve herhangi bir hata olmadan çalışır.

1- Yorum Bu kod parçası:

   <!--<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>--> 

2- çalıştırmak uygulama.

3- ni kod parçası:

   <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> 

4- çalıştırma uygulaması.

0

ad doğru olması, ithal etmek doğru yoludur:

xmlns:data="clr-namespace:OrnekUygulama.Model" 
+0

Bu bana daha fazla talihsizlik verdi. Ama bir kullanıcı kontrolü oluşturdum ve hepsini içeri aldım. Sanırım çözdüm. –