2016-06-19 16 views
0

いくつかのバグのためのバインディングページと、私のアプリケーションのコメント用のもう1つのバグページがあります。最初のものは正常に動作しますが、2番目のものは何も表示されませんが、データ(21コメント)は正常に読み込まれます。 私はそれらのオプションを持っているライブライブ財産Explorerと最初のグリッドに外観を取ってきた: enter image description hereGridView UWPでバインドする際の問題

しかし、第2の1ののItemsSourceがヌルとして設定されている: enter image description here

これはすべきではありませんこれらのアイテムには変更がほとんどない同じコードがあるため、読み込みが異なるためです。 ここでは、コードを持っている:

<Page.Resources> 
     <DataTemplate x:DataType="data:Book" x:Key="BookDataTemplate"> 
      <StackPanel HorizontalAlignment="Center"> 
       <Image Width="150" Height="150" Source="{x:Bind CoverImage}" /> 
       <StackPanel HorizontalAlignment="center" Orientation="Horizontal"> 
        <TextBlock FontSize="10" Text="{x:Bind DScore}" HorizontalAlignment="Center" Foreground="#FF21C721" /> 
        <TextBlock FontSize="10" Text="{x:Bind DFav}" HorizontalAlignment="Center" Foreground="#FF9C9C9C" /> 
       </StackPanel> 
       <TextBlock FontSize="16" Text="{x:Bind Title}" HorizontalAlignment="Center" Foreground="White" /> 
       <TextBlock FontSize="10" Text="{x:Bind Author}" HorizontalAlignment="Center" Foreground="#FF9C9C9C" /> 
       <ToolTipService.ToolTip> 
        <TextBlock Text="{x:Bind DData}"/> 
       </ToolTipService.ToolTip> 
      </StackPanel> 
     </DataTemplate> 
    </Page.Resources> 

<GridView ItemsSource="{x:Bind Books}" AllowDrop="True" IsSwipeEnabled="True" IsItemClickEnabled="True" ItemClick="Content_ItemClick" Name="Content" Margin="0,100,0,40" CanReorderItems="True" 
        CanDragItems="True" 
        ItemTemplate="{StaticResource BookDataTemplate}" ReorderMode="Enabled"/> 

とコメントのGridView:

<Page.Resources> 
     <DataTemplate x:DataType="data:Comment" x:Key="CommentDataTemplate"> 
      <StackPanel HorizontalAlignment="Center"> 
      <Grid> 
       <Rectangle Margin="50, 0, 0, 30" Fill="#FF144772" Height="100" Stroke="Black" Width="500" HorizontalAlignment="Center"/> 
       <Rectangle Margin="60, 0, 0, 45" Fill="#FF031131" Height="60" Stroke="Black" Width="60" HorizontalAlignment="Left"/> 
       <Rectangle Margin="140, 0, 0, 25" Fill="#FF103F91" Height="60" Stroke="Black" Width="360" HorizontalAlignment="Left"/> 
       <Image x:Name="image" HorizontalAlignment="Left" Height="50" Margin="65,18,0,0" VerticalAlignment="Top" Width="50" Source="Assets/profile.png"/> 
       <StackPanel HorizontalAlignment="center" Orientation="Horizontal"> 
        <TextBlock Margin="0, 70, 400, 0" FontSize="10" Text="{x:Bind Date}" HorizontalAlignment="Center" Foreground="#FF9C9C9C" /> 
       </StackPanel> 
       <TextBlock Margin="130, 0, 0, 0" FontSize="16" Text="{x:Bind Author}" HorizontalAlignment="Left" Foreground="White" /> 
       <TextBlock Margin="150, 30, 0, 0" FontSize="11" Text="{x:Bind Body}" Width="360" HorizontalAlignment="Left" Foreground="#FF9C9C9C" /> 
       <ToolTipService.ToolTip> 
        <TextBlock Text="{x:Bind Score}"/> 
       </ToolTipService.ToolTip> 
      </Grid> 
       </StackPanel> 
     </DataTemplate> 
    </Page.Resources> 

<GridView ItemsSource="{x:Bind Comments}" AllowDrop="True" IsSwipeEnabled="True" IsItemClickEnabled="True" Name="Content" Margin="0,100,0,40" CanReorderItems="True" 
          CanDragItems="True" 
          ItemTemplate="{StaticResource CommentDataTemplate}" ReorderMode="Enabled"/> 

は、誰かが私がここで問題にしてください識別するのに役立つことはできますか?

答えて

1

2番目のページのXAMLファイルで、ItemsSourceの「Comments」に移動し、F12キーを押します。コメントの定義に移動できる場合は、バインディングは成功していますが、コメントには値が設定されていません。定義にナビゲートできなかった場合、バインディングは機能していません。その場合、そのページにdatacontextが設定されているかどうかを確認してください。また、XAMLとプロパティで「コメント」の綴りを確認します。

+0

修正ありがとうございました! – Onelio

関連する問題