private void Elements_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (!(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Move))
            {
                if (!DataModel.Instance.IsPowerwall)
                {
                    StackTrace stackTrace = new StackTrace();
                    if (stackTrace.ToString().Contains("System.Windows.Controls"))
                    {
                        if (e.OldItems != null)
                        {
                            List <int> ouToRemove = new List <int>();

                            foreach (var item in e.OldItems)
                            {
                                OrganizationalUnit ou = item as OrganizationalUnit;
                                if (ou != null)
                                {
                                    ouToRemove.Add(ou.ID);
                                }
                            }

                            if (ouToRemove.Count > 0)
                            {
                                WorkerThread workerThread = ThreadManager.CreateWorkerThread("BackSync_OrganizationalUnit.Elements", () =>
                                {
                                    bool result = DataModel.Instance.SyncBackOURemoved(ouToRemove);
                                }, false);
                            }
                        }

                        if (e.NewItems != null)
                        {
                            List <OrganizationalUnit> ouToAdd = new List <OrganizationalUnit>();

                            foreach (var item in e.NewItems)
                            {
                                OrganizationalUnit ou = item as OrganizationalUnit;
                                if (ou != null)
                                {
                                    ouToAdd.Add(ou);
                                }
                            }

                            if (ouToAdd.Count > 0)
                            {
                                WorkerThread workerThread = ThreadManager.CreateWorkerThread("BackSync_OrganizationalUnit.Elements", () =>
                                {
                                    bool result = DataModel.Instance.SyncBackOUAdd(ouToAdd);
                                }, false);
                            }
                        }
                    }
                    stackTrace = null;
                }
            }
        }
 protected override void MoveElement(int ID, float Value)
 {
     if (this.ID == ID)
     {
         Application.Current.Dispatcher.Invoke(() =>
         {
             OrganizationalUnit ou = DataModel.Instance.GetOu(OuID);
             if (ou != null)
             {
                 ExtendedObservableCollection <TileableElement> children = ou.Elements;
                 children.Sort();
             }
         });
     }
 }