private static ContentPane EnsureDockWindow(object view) { var window = view as ContentPane; if (window == null) { window = new ContentPane { CloseAction = PaneCloseAction.RemovePane, Content = view as UIElement }; window.SetValue(View.IsGeneratedProperty, true); } return(window); }
/// <summary> /// Prepares a view being injected as a ContentPane /// </summary> /// <param name="item">the view</param> /// <returns>The injected view as a ContentPane</returns> protected ContentPane PrepareContainerForItem(object item, IRegion region) { ContentPane container = item as ContentPane; if (container == null) { container = new ContentPane(); container.Content = item; //the content is the item being injected container.DataContext = ResolveDataContext(item); //make sure the dataContext is the same as the item. Most likely a ViewModel container.SetValue(IsGeneratedProperty, true); //we generated this one CreateDockAwareBindings(container); } container.SetValue(RegionProperty, region); //let's keep track of which region the container belongs to container.CloseAction = PaneCloseAction.RemovePane; //make it easy on ourselves and have the pane manage removing itself from the XamDockManager container.Closed += Container_Closed; return(container); }
internal static void SetAssociatedProxy(ContentPane pane, ContentPaneProxy value) { pane.SetValue(AssociatedProxyPropertyKey, value); }
private static ContentPane EnsureDockWindow(object view) { var window = view as ContentPane; if(window == null) { window = new ContentPane { CloseAction = PaneCloseAction.RemovePane, Content = view as UIElement }; window.SetValue(View.IsGeneratedProperty, true); } return window; }
/// <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); } }