protected virtual void RemovePane(ContentPane cp) { var closeProp = ContentPane.CloseActionProperty; if (cp == null) { return; } var oldValue = cp.ReadLocalValue(closeProp); BindingExpressionBase oldExpression = cp.GetBindingExpression(closeProp); cp.CloseAction = PaneCloseAction.RemovePane; if (oldExpression != null) { cp.SetBinding(closeProp, oldExpression.ParentBindingBase); } else if (oldValue == DependencyProperty.UnsetValue) { cp.ClearValue(closeProp); } else { cp.SetValue(closeProp, oldValue); } cp.PreviewMouseDown -= PaneOnPreviewMouseDown; }
/// <summary> /// Invoked when a ContentPane for a given item is being removed. /// </summary> /// <param name="cp">The pane being removed</param> protected virtual void RemovePane(ContentPane cp) { // we need to temporarily change the close action while we close it DependencyProperty closeProp = ContentPane.CloseActionProperty; if (cp == null) { return; } object oldValue = cp.ReadLocalValue(closeProp); BindingExpressionBase oldExpression = cp.GetBindingExpression(closeProp); cp.CloseAction = PaneCloseAction.RemovePane; // restore the original close action if (oldExpression != null) { cp.SetBinding(closeProp, oldExpression.ParentBindingBase); } else if (oldValue == DependencyProperty.UnsetValue) { cp.ClearValue(closeProp); } else { cp.SetValue(closeProp, oldValue); } cp.PreviewMouseDown -= PaneOnPreviewMouseDown; }
/// <summary> /// Invoked when a ContentPane for a given item is being removed. /// </summary> /// <param name="cp">The pane being removed</param> protected virtual void RemovePane(ContentPane cp) { // we need to temporarily change the close action while we close it DependencyProperty closeProp = ContentPane.CloseActionProperty; if(cp == null) { return; } object oldValue = cp.ReadLocalValue(closeProp); BindingExpressionBase oldExpression = cp.GetBindingExpression(closeProp); cp.CloseAction = PaneCloseAction.RemovePane; // restore the original close action if(oldExpression != null) { cp.SetBinding(closeProp, oldExpression.ParentBindingBase); } else if(oldValue == DependencyProperty.UnsetValue) { cp.ClearValue(closeProp); } else { cp.SetValue(closeProp, oldValue); } }