/// <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; }
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> /// Sets the Content property of a generated ContentPane to null. /// </summary> /// <param name="contentPane">The ContentPane</param> protected void ClearContainerForItem(ContentPane contentPane) { if ((bool)contentPane.GetValue(IsGeneratedProperty)) { contentPane.ClearValue(ContentPane.HeaderProperty); //remove any bindings contentPane.Content = null; } }
/// <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); } }