Пример #1
0
        /// <summary>
        /// Handles the Loaded event of this control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void This_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                this.NodeViewer = LayoutHelper.FindLogicalParent <UcNodeViewer>(this, true);
                if (this.NodeViewer == null)
                {
                    this.NodeViewer = LayoutHelper.FindVisualParent <UcNodeViewer>(this, true);
                }

                if (this.NodeViewer != null && !this.IsPreview)
                {
                    this.treeDesigner = LayoutHelper.FindLogicalParent <UcTreeDesigner>(this.NodeViewer, true);
                    if (this.treeDesigner != null)
                    {
                        this.treeDesigner.RegisterIOHandle(this);

                        DisposablesHandler.Instance.AddDisposeConnection(this,
                                                                         PropertyChangedHandle.GetDistinctInstance(this.treeDesigner, "ConnectingIOHandle", this.OnTreeDesignerConnectingIOHandleChanged));
                    }

                    DisposablesHandler.Instance.AddDisposeConnection(this,
                                                                     PropertyChangedHandle.GetDistinctInstance(this.NodeViewer, "IsSelected", this.OnNodeViewerIsSelectedChanged));
                }
            }
            LoadedCompletely = true;
        }
Пример #2
0
        /// <summary>
        /// Handles the MouseLeftButtonUp event of the DataGridOwner control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
        private void DataGridOwner_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            // If expansion on click on row is enabled this event handler is called when
            // a user clicks on a row.

            // Make sure that the click was inside the selected row.
            if (this.DataGridOwner != null)
            {
                DataGridRow row = LayoutHelper.FindVisualParent <DataGridRow>(e.OriginalSource as UIElement);
                if (row != null && row.Item == this.DataGridOwner.SelectedItem &&
                    LayoutHelper.FindVisualParent <DataGridDetailsPresenter>(e.OriginalSource as UIElement) == null)
                {
                    // toggle expansion.
                    this.ToggleExpansionOfSelected();
                }
            }
        }