BindPath() публичный статический Метод

Binds the specified target property to the specified path property.
public static BindPath ( DependencyObject container, object item, string path, DependencyProperty targetProperty ) : void
container System.Windows.DependencyObject The element associated with the item
item object The underlying data item
path string The path property to provide the value for the specified
targetProperty System.Windows.DependencyProperty The property whose value is to come from the specified path of the underlying data item.
Результат void
Пример #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;
                    }
                }
            }
        }