You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a system to redo/undo with the whole canvas elements of my program with muf.
canvas elements is bound to ObservableCollection<FrameworkElement> and everytime user add/remove the element, it goes to the property
public CustomCollection<FrameworkElement> m_CanvasElements = new CustomCollection<FrameworkElement>();
public CustomCollection<FrameworkElement> CanvasElements
{
get {
return m_CanvasElements; }
set {
m_CanvasElements = value;
OnPropertyChanged("CanvasElements");
}
}
And here's what I've tried to do. I made an inherited class of ObservableCollection to use an NotifyCollectionChangedEventArgs as a parameter.
public class CustomCollection<T> : ObservableCollection<T>, ICloneable
{
public event EventHandler<NotifyCollectionChangedEventArgs> ItemAdded;
public CustomCollection()
{
CollectionChanged += MyObservableCollection_CollectionChanged;
}
void MyObservableCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
DefaultChangeFactory.Current.OnCollectionChanged(this, "CanvasElements", MainWindow.VM.m_CanvasElements, e);
...
}
I have tried both OnCollectionChanged and GetCollectionChange. and it seems doesn't work.
Currently, OnChanging is working exactly that I expected.
Any ideas?
The text was updated successfully, but these errors were encountered:
My mistake
I had to change DefaultChangeFactory.Current.OnCollectionChanged(this, "CanvasElements", MainWindow.VM.m_CanvasElements, e);
to DefaultChangeFactory.Current.OnCollectionChanged(MainWindow.VM, "CanvasElements", MainWindow.VM.m_CanvasElements, e);
I'm trying to create a system to redo/undo with the whole canvas elements of my program with muf.
canvas elements is bound to
ObservableCollection<FrameworkElement>
and everytime user add/remove the element, it goes to the propertyAnd here's what I've tried to do. I made an inherited class of
ObservableCollection
to use anNotifyCollectionChangedEventArgs
as a parameter.I have tried both
OnCollectionChanged
andGetCollectionChange
. and it seems doesn't work.Currently,
OnChanging
is working exactly that I expected.Any ideas?
The text was updated successfully, but these errors were encountered: