コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the WantedMoviesViewModel class.
        /// </summary>
        public WantedMoviesViewModel(IMovieService moviesService)
        {
            // The data service
            _moviesService = moviesService;

            // Get all the movies and add them to the Movies collection
            Movies = new ObservableCollection<MovieViewModel>();
            _moviesService.GetWanted((result, error) =>
            {
                if (error != null)
                {
                    MessageBox.Show(error.Message);
                    return;
                }

                if (result == null)
                {
                    MessageBox.Show("Nothing found");
                    return;
                }

                foreach (var movie in result)
                {
                    Movies.Add(new MovieViewModel(movie));
                }
            });
            SelectionChangedCommand = new RelayCommand<MovieViewModel>((msg) => OnSelectionChanged(msg));
            //SelectionChangedCommand = new RelayCommand<SelectionChangedEventArgs>(e => OnSelectionChanged(e));
        }