Ejemplo n.º 1
0
 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();
                     }
                 }
             }
         };
     }
 }
Ejemplo n.º 2
0
 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();
             }
         });
     }
 }
Ejemplo n.º 3
0
 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();
             }
         });
 }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
 /// <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);
 }