Exemplo n.º 1
0
 private static void OnTombstonerChanged(FrameworkElement obj, Tombstoner oldValue, Tombstoner 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();
             }
         });
     }
 }
Exemplo n.º 2
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)
                 {
                     Tombstoner ts = GetTombstoner((FrameworkElement)item.Target);
                     if (ts != null)
                     {
                         ts.Tombstone();
                     }
                 }
             }
         };
     }
 }
Exemplo n.º 3
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, Tombstoner value)
 {
     obj.SetValue(TombstonerProperty, value);
 }