0

我正在将电影列表显示为我的 Windows Phone 7 应用程序的全景图。单击每部电影正在显示电影详细信息,演员表。电影细节,演员表显示为枢轴控件。电影细节效果很好但是当我展示演员时,它不起作用。我有演员表。并将源绑定到 cast pivot 控件中的列表框,但它不显示任何数据。请帮我。以下是我使用过的课程。谢谢

主视图模型.cs

public class MainViewModel
{
    public ObservableCollection<ItemViewModel> MovieItems { get; set; }

 }

项目视图模型.cs

 public class ItemViewModel : INotifyPropertyChanged
{

     private string _title;
     public string _Title
      {
        get { return _title; }

        set
        {
            if (value != _title)
            {
                _title = value;
                NotifyPropertyChanged("title");
            }
        }
    }


      private ObservableCollection<Cast> _cast;

    public ObservableCollection<Cast> _Cast
    {
        get { return _cast; }

        set
        {
            if (value != _cast)
            {
                _cast = value;
                NotifyPropertyChanged("Cast");
            }
        }
    }
  ..........

}

Cast.cs

public class Cast
 {
      public string name { get; set; }
      public string imagesource { get; set; }


      public Cast(string _name, string _imagesource)
      {
        this.imagesource = _imagesource;
        this.name = _name;
      }
 }
for each movie i have a list of cast objects

电影模型.cs

                  App.Model.MovieItems.Add(
                   new ItemViewModel()
                   {
                       _Title = data["title"].ToString(),
                       _Cast=casObs,
                      ........
                   }
                   );

电影细节.xml

               <ListBox Name="ListBox" Margin="0,0,-12,0" ItemsSource="{Binding _Cast}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,0,0,17" Width="432" Height="78">
                            <Canvas>
                                <TextBlock HorizontalAlignment="Center"   VerticalAlignment="Bottom" Margin="120,5,60,3" Text="{Binding name}" TextWrapping="Wrap" FontSize="32" Style="{StaticResource PhoneTextNormalStyle}"/>
                                <Image Height="90" HorizontalAlignment="Left" Margin="12,10,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="90" Source="{Binding imagesource}" />
                            </Canvas>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
4

2 回答 2

0

代替

NotifyPropertyChanged("title");

NotifyPropertyChanged("_Title"); 

NotifyPropertyChanged("Cast");

NotifyPropertyChanged("_Cast");

希望有帮助。

于 2013-04-25T12:39:12.570 回答
0

在中间应用转换器,您需要返回 ImageSource/BitmapImage,而不是字符串

于 2013-05-22T18:22:47.440 回答