0

我在绑定数据方面需要帮助,尤其是在根数据源对象有很多子类并且这些子类也有子类的情况下。这是我的数据模型:

public class NowShowingMovies
{
  public ObservableCollection<Movie> MovieCollection { get; set; }
  public string Status { get; set; }
  public string Total{ get; set; }
}
public class Movie
{
  public string Id {get;set;}
  public string Title {get;set}
  public UserRating Rating {get;set;}
}
public class UserRating
{
  public string UserRatingURL {get;set;}
}

我的 XAML 代码是:

<GridView ItemsSource="{Binding MovieCollection}"
<GridView.ItemTemplate>
     <DataTemplate>
        <Grid>
            <Border Background="White">
                   <TexBlock Text="{Binding Title}"/>
            </Border>
             <Grid Background="Black" Margin="0,0,0,0" Opacity="0.75" x:Name="grid_rating"/>
                                <Image Source ="{Binding Path=MovieCollection.Rating.UserRatingURL}" />
             </Grid>
     </DataTemplate>
 </GridView.ItemTemplate>
 </GridView>

问题是我不能让它工作。UserRatingURL 未显示。我什至将其更改为

<Image Source ="{Binding Path=MovieCollection[0].Rating.UserRatingURL}" />

仍然没有运气。我究竟做错了什么?提前致谢!

4

1 回答 1

0

尝试删除路径中的 MovieCollection。

图片来源="{绑定路径=Rating.UserRatingURL}"

于 2013-10-08T03:22:47.093 回答