private static void Initialize() { if (DesignerProperties.IsInDesignTool) { return; } if (PhoneApplicationService.Current == null) { Deployment.Current.Dispatcher.BeginInvoke(Initialize); } else { PhoneApplicationService.Current.Deactivated += (o, a) => { foreach (var item in ElementsToTombstone) { if (item.IsAlive) { Epitaph ts = GetTombstoner((FrameworkElement)item.Target); if (ts != null) { ts.Tombstone(); } } } }; } }
private static void OnTombstonerChanged(FrameworkElement obj, Epitaph oldValue, Epitaph newValue) { if (DesignerProperties.IsInDesignTool) { return; } if (oldValue != null) { oldValue.Parent = null; } if (newValue != null) { newValue.Parent = obj; ElementsToTombstone.Add(new WeakReference(obj)); CleanupElementsToTombstone(); } if (newValue != null) { obj.Dispatcher.BeginInvoke(() => { try { newValue.CalculateTombstoneId(); } catch { obj.Loaded += (o, a) => newValue.CalculateTombstoneId(); } }); } }
private static void OnTombstonerChanged(FrameworkElement obj, Epitaph oldValue, Epitaph newValue) { if (DesignerProperties.IsInDesignTool) return; if (oldValue != null) oldValue.Parent = null; if (newValue != null) { newValue.Parent = obj; ElementsToTombstone.Add(new WeakReference(obj)); CleanupElementsToTombstone(); } if (newValue != null) obj.Dispatcher.BeginInvoke(() => { try { newValue.CalculateTombstoneId(); } catch { obj.Loaded += (o, a) => newValue.CalculateTombstoneId(); } }); }
/// <summary> /// Sets the tombstoner for the control. /// </summary> /// <param name="obj">The control being tombstoned.</param> /// <param name="value">The tombstoner for the control.</param> public static void SetTombstoner(FrameworkElement obj, Epitaph value) { obj.SetValue(TombstonerProperty, value); }