My loading data to grid look like this:
MainForm.cs
public MainForm()
{
InitializeComponent();
_mainWindowViewModel = new MainWindowViewModel();
dgvMovies.DataSource = _mainWindowViewModel.MovieRowsViewModels;
}
MainWindowViewModel.cs
public List<MovieRowViewModel> MovieRowsViewModels
{
get
{
return _movieRepository.GetAll().Select(n => new MovieRowViewModel
{
ID = n.ID,
Title = n.Title,
Year = n.Year,
Poster = n.Poster
}).ToList();
}
}
Method GetAll()
public IQueryable<Model.Movie> GetAll()
{
using (var db = new Context())
{
return db.Movie.ToList().AsQueryable();
}
}
and the MovieRowViewModel.cs
class MovieRowViewModel
{
public int ID { get; set; }
public string Title { get; set; }
public int Year { get; set; }
public string Poster { get; set; }
}
Question is how to load image from the url to this grid?
That worked for me:
I have found it in this answer, so credit to jmservera
EDIT: If you want to specify the size of the loaded image, you need to check out all
Bitmap
constructors:There is:
when it comes to loading image from URI, you have to change...