I have a ViewModel class that contains a list of points, and I am trying to bind it to a Polyline. The Polyline picks up the initial list of points, but does not notice when
Change your PointCollections Property to a dependency property:
public PointCollection Pts
{
get { return (PointCollection)GetValue(PtsProperty); }
set { SetValue(PtsProperty, value); }
}
// Using a DependencyProperty as the backing store for Pts. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PtsProperty =
DependencyProperty.Register("Pts", typeof(PointCollection), typeof(ViewModel), new UIPropertyMetadata(new PointCollection()));
BTW Doing this, you won't need to fire the PropertyChanged event.
Oh sorry, and your object needs to inherit from DependencyObject
public class ViewModel : DependencyObject
{
//...
}
i got it to work as a POCO by implementing INotifyCollectionChanged instead of INotifyPropertyChanged.
It is quite likely that since it is binding to the collection, it will need something like ObservableCollection<T>
. What happens if you switch from PointCollection
to ObservableCollection<Point>?