I want to update the movie information in some text blocks depending on the selected movie
I have
public Movie SelectedMovie { get; set; }
in my viewmodel model, which is what my datacontext is set to
And whenever a movie is selected on my list, it updates "SelectedMovie"
But only the first movie updates the text block
<TextBlock Grid.ColumnSpan="2" Text="{Binding Path=SelectedMovie.Name}" FontSize="17" />
(the one that is selected when downloading the application)
So itβs not entirely clear why he doesnβt change the text when I select a new movie from the list?
Movie Class:
using System;
using System.ComponentModel;
namespace MovieDB3.Models
{
class Movie : INotifyPropertyChanged
{
public Movie(string name)
{
this.name = name;
}
private string name;
public string Name
{
get { return name; }
set
{
name = value;
InvokePropertyChanged("Name");
}
}
public int Id { get; set; }
private double rating;
public double Rating
{
get { return rating; }
set
{
rating = value;
InvokePropertyChanged("Rating");
}
}
public DateTime Release { get; set; }
public TimeSpan Runtime { get; set; }
public String Trailer { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
private void InvokePropertyChanged(String propertyName)
{
PropertyChangedEventArgs e = new PropertyChangedEventArgs(propertyName);
PropertyChangedEventHandler changed = PropertyChanged;
if (changed != null) changed(this, e);
}
}
}
source
share