Static class with methods relating to binding
コード例 #1
0
        /// <summary>
        /// Used to initialize a container for a given item.
        /// </summary>
        /// <param name="container">The container element </param>
        /// <param name="item">The item from the source collection</param>
        protected override void PrepareContainerForItem(DependencyObject container, object item)
        {
            BindingHelper.BindPath(container, item, HeaderPath, HeaderedContentControl.HeaderProperty);
            BindingHelper.BindPath(container, item, ContentPath, ContentControl.ContentProperty);
            BindingHelper.BindPath(container, item, TabHeaderPath, ContentPane.TabHeaderProperty);

            base.PrepareContainerForItem(container, item);

            ContentPane pane = container as ContentPane;

            SetTabName(pane, item);

            //Aded to prevent tab from stealing focus from adorners
            //FocusManager.SetIsFocusScope(pane, false);
            if (pane != null)
            {
                pane.PreviewLostKeyboardFocus += pane_PreviewLostKeyboardFocus;
                pane.PreviewGotKeyboardFocus  += pane_PreviewLostKeyboardFocus;
                pane.PreviewMouseDown         += PaneOnPreviewMouseDown;
                // always hook the closed
                pane.Closed  += OnPaneClosed;
                pane.Closing += OnPaneClosing;

                //Juries attach to events when viewmodel is closed/deactivated to close view.
                WorkSurfaceContextViewModel model = item as WorkSurfaceContextViewModel;
                if (model != null)
                {
                    var vm = model;
                    vm.Deactivated += ViewModelDeactivated;
                }


                if (RemoveItemOnClose)
                {
                    IEditableCollectionView cv = CollectionViewSource.GetDefaultView(ItemsSource) as IEditableCollectionView;

                    // set the pane to be removed from the dockmanager
                    pane.CloseAction = PaneCloseAction.RemovePane;

                    if (null == cv || !cv.CanRemove)
                    {
                        pane.AllowClose = false;
                    }
                }
            }
        }
コード例 #2
0
        protected override void PrepareContainerForItem(DependencyObject container, object item)
        {
            BindingHelper.BindPath(container, item, HeaderPath, HeaderedContentControl.HeaderProperty);
            BindingHelper.BindPath(container, item, ContentPath, ContentControl.ContentProperty);
            BindingHelper.BindPath(container, item, TabHeaderPath, ContentPane.TabHeaderProperty);

            base.PrepareContainerForItem(container, item);

            var pane = container as ContentPane;

            SetTabName(pane, item);

            if (pane != null)
            {
                pane.PreviewLostKeyboardFocus += pane_PreviewLostKeyboardFocus;
                pane.PreviewGotKeyboardFocus  += pane_PreviewLostKeyboardFocus;
                pane.PreviewMouseDown         += PaneOnPreviewMouseDown;
                pane.Closed  += OnPaneClosed;
                pane.Closing += OnPaneClosing;

                if (item is WorkSurfaceContextViewModel model)
                {
                    var vm = model;
                    vm.Deactivated += ViewModelDeactivated;
                }


                if (RemoveItemOnClose)
                {
                    var cv = CollectionViewSource.GetDefaultView(ItemsSource) as IEditableCollectionView;

                    pane.CloseAction = PaneCloseAction.RemovePane;

                    if (null == cv || !cv.CanRemove)
                    {
                        pane.AllowClose = false;
                    }
                }
            }
        }