Hi,
I have the following class:
public class MyCustomCanvas : Canvas
{
public static readonly DependencyProperty SpritesProperty = DependencyProperty.Register(
"Sprites",
typeof(ObservableCollection<Sprite>),
typeof (MyCustomCanvas),
new FrameworkPropertyMetadata(
null,
FrameworkPropertyMetadataOptions.AffectsRender|FrameworkPropertyMetadataOptions.AffectsParentMeasure));
public ObservableCollection<Sprite> Sprites
{
get { return (ObservableCollection<Sprite>) GetValue(SpritesProperty); }
set { SetValue(SpritesProperty, value); }
}
The Sprite class implements INotifyPropertyChanged
. the Sprites property is bound to some other collection.
What I'm trying to achieve, is that whenever a property changes in a sprite that's in the collection OR whenever I add or remove items in the collection, the canvas redraws itself.
I know I could add a function to each sprite's Property Changed event handler, but I wanted to know if there's a nicer way to do this.
Thanks in advance.