tags:

views:

42

answers:

1

I created class:

class StorageBase
{
    public Queue<Slices> Slices {get;set;}
}

and wpf custom control which has dependency property Storage of type StorageBase:

public StorageBase Storage
        {
            get { return (StorageBase)GetValue(StorageProperty); }
            set { SetValue(StorageProperty, value); }
        }
        public static readonly DependencyProperty StorageProperty =
            DependencyProperty.Register("Storage", typeof(StorageBase), typeof(MaterialStreamControl), new UIPropertyMetadata(null, new PropertyChangedCallback(OnStoragePropertyChanged)));
        static void OnStoragePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as MaterialStreamControl).Render();
        }

How could I rerender the component if slices in Storage changed?

A: 

Normally StorageBase would implement INotifyPropertyChanged. The setter on Slices would then raise the INotifyPropertyChanged.PropertyChanged event.

Example: http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.propertychanged.aspx

EDIT: You may also want to make Slices an ObservableCollection instead of a Queue. http://msdn.microsoft.com/en-us/library/ms668604.aspx

Jonathan Allen
First method doesn't work. When I add slice to Slices the OnStoragePropertyChanged doesn't raise.Second method doesn't suitable cause I need only queue.
JohnKZ
You can use an ObservableCollection as if it were a queue. Alternately you can create your own Queue class that implements IObservableCollection.
Jonathan Allen