Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit c4d7257d authored by Harald Martini's avatar Harald Martini
Browse files

Unsubscribe from PropertyDescriptor in Autoscrolldatagridbehaviour

parent 60bc1c84
No related branches found
No related tags found
No related merge requests found
......@@ -16,15 +16,17 @@ namespace VECTO3GUI2020.Behaviours
#region Overrides of Behavior
private INotifyCollectionChanged sourceCollection;
private DependencyPropertyDescriptor _dpd;
protected override void OnAttached()
{
base.OnAttached();
//subsrice to Itemssource
var dpd = DependencyPropertyDescriptor.FromProperty(ItemsControl.ItemsSourceProperty, typeof(DataGrid));
if (dpd != null)
_dpd = DependencyPropertyDescriptor.FromProperty(ItemsControl.ItemsSourceProperty, typeof(DataGrid));
if (_dpd != null)
{
dpd.AddValueChanged(this.AssociatedObject, OnItemsSourceChanged);
_dpd.AddValueChanged(this.AssociatedObject, OnItemsSourceChanged);
}
......@@ -58,6 +60,10 @@ namespace VECTO3GUI2020.Behaviours
{
base.OnDetaching();
UnSubscribeFromSourceCollectionChanged();
if (_dpd != null)
{
_dpd.RemoveValueChanged(this.AssociatedObject, OnItemsSourceChanged);
}
}
private void UnSubscribeFromSourceCollectionChanged()
......@@ -65,6 +71,7 @@ namespace VECTO3GUI2020.Behaviours
if (sourceCollection != null) {
sourceCollection.CollectionChanged -= SourceCollectionChanged;
}
}
#endregion
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment