private static void OnItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctrl = d as GalleryPreviewControl;
if (e.OldValue != null)
{
if (e.OldValue is INotifyCollectionChanged)
{
(e.OldValue as INotifyCollectionChanged).CollectionChanged -= ctrl.GalleryPreviewControl_CollectionChanged;
}
}
if (e.NewValue != null)
{
if (e.NewValue is INotifyCollectionChanged)
{
(e.NewValue as INotifyCollectionChanged).CollectionChanged += ctrl.GalleryPreviewControl_CollectionChanged;
}
}
ctrl.Children.Clear();
ctrl.InvalidateMeasure();
}