Пример #1
0
 private void TreeViewItemTemplateApplied(object sender, TemplateAppliedEventArgs e)
 {
     var item = (TreeViewItem)sender;
     var header = item.HeaderPresenter.Child;
     header.PointerEnter += AddAdorner;
     header.PointerLeave += RemoveAdorner;
     item.TemplateApplied -= TreeViewItemTemplateApplied;
 }
Пример #2
0
        /// <summary>
        /// Builds the visual tree for the row header when a new template is applied.
        /// </summary>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            _rootElement = e.NameScope.Find <Control>(DATAGRIDROWHEADER_elementRootName);
            if (_rootElement != null)
            {
                ApplyOwnerStatus();
            }
        }
Пример #3
0
        /// <summary>
        /// Builds the visual tree for the
        /// <see cref="T:System.Windows.Controls.Primitives.CalendarItem" />
        /// when a new template is applied.
        /// </summary>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            HeaderButton   = e.NameScope.Find <Button>(PART_ElementHeaderButton);
            PreviousButton = e.NameScope.Find <Button>(PART_ElementPreviousButton);
            NextButton     = e.NameScope.Find <Button>(PART_ElementNextButton);
            MonthView      = e.NameScope.Find <Grid>(PART_ElementMonthView);
            YearView       = e.NameScope.Find <Grid>(PART_ElementYearView);

            if (Owner != null)
            {
                UpdateDisabled(Owner.IsEnabled);
            }

            PopulateGrids();

            if (MonthView != null && YearView != null)
            {
                if (Owner != null)
                {
                    Owner.SelectedMonth = Owner.DisplayDateInternal;
                    Owner.SelectedYear  = Owner.DisplayDateInternal;

                    if (Owner.DisplayMode == CalendarMode.Year)
                    {
                        UpdateYearMode();
                    }
                    else if (Owner.DisplayMode == CalendarMode.Decade)
                    {
                        UpdateDecadeMode();
                    }

                    if (Owner.DisplayMode == CalendarMode.Month)
                    {
                        UpdateMonthMode();
                        MonthView.IsVisible = true;
                        YearView.IsVisible  = false;
                    }
                    else
                    {
                        YearView.IsVisible  = true;
                        MonthView.IsVisible = false;
                    }
                }
                else
                {
                    UpdateMonthMode();
                    MonthView.IsVisible = true;
                    YearView.IsVisible  = false;
                }
            }
        }
Пример #4
0
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            if (_lineUpButton != null)
            {
                _lineUpButton.Click -= LineUpClick;
            }

            if (_lineDownButton != null)
            {
                _lineDownButton.Click -= LineDownClick;
            }

            if (_pageUpButton != null)
            {
                _pageUpButton.Click -= PageUpClick;
            }

            if (_pageDownButton != null)
            {
                _pageDownButton.Click -= PageDownClick;
            }

            _lineUpButton   = e.NameScope.Find <Button>("PART_LineUpButton");
            _lineDownButton = e.NameScope.Find <Button>("PART_LineDownButton");
            _pageUpButton   = e.NameScope.Find <Button>("PART_PageUpButton");
            _pageDownButton = e.NameScope.Find <Button>("PART_PageDownButton");



            if (_lineUpButton != null)
            {
                _lineUpButton.Click += LineUpClick;
            }

            if (_lineDownButton != null)
            {
                _lineDownButton.Click += LineDownClick;
            }

            if (_pageUpButton != null)
            {
                _pageUpButton.Click += PageUpClick;
            }

            if (_pageDownButton != null)
            {
                _pageDownButton.Click += PageDownClick;
            }
        }
Пример #5
0
        /// <inheritdoc/>
        public sealed override void ApplyTemplate()
        {
            var template = Template;
            var logical  = (ILogical)this;

            // Apply the template if it is not the same as the template already applied - except
            // for in the case that the template is null and we're not attached to the logical
            // tree. In that case, the template has probably been cleared because the style setting
            // the template has been detached, so we want to wait until it's re-attached to the
            // logical tree as if it's re-attached to the same tree the template will be the same
            // and we don't need to do anything.
            if (_appliedTemplate != template && (template != null || logical.IsAttachedToLogicalTree))
            {
                if (VisualChildren.Count > 0)
                {
                    foreach (var child in this.GetTemplateChildren())
                    {
                        child.SetValue(TemplatedParentProperty, null);
                        ((ISetLogicalParent)child).SetParent(null);
                    }

                    VisualChildren.Clear();
                }

                if (template != null)
                {
                    Logger.TryGet(LogEventLevel.Verbose, LogArea.Control)?.Log(this, "Creating control template");

                    var(child, nameScope) = template.Build(this);
                    ApplyTemplatedParent(child);
                    ((ISetLogicalParent)child).SetParent(this);
                    VisualChildren.Add(child);

                    // Existing code kinda expect to see a NameScope even if it's empty
                    if (nameScope == null)
                    {
                        nameScope = new NameScope();
                    }

                    var e = new TemplateAppliedEventArgs(nameScope);
                    OnApplyTemplate(e);
#pragma warning disable CS0618 // Type or member is obsolete
                    OnTemplateApplied(e);
#pragma warning restore CS0618 // Type or member is obsolete
                    RaiseEvent(e);
                }

                _appliedTemplate = template;
            }
        }
        protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
        {
            base.OnApplyTemplate(e);

            void ExecuteScrollWhenLayoutUpdated(object?sender, EventArgs e)
            {
                LayoutUpdated -= ExecuteScrollWhenLayoutUpdated;
                AutoScrollToSelectedItemIfNecessary();
            }

            if (AutoScrollToSelectedItem)
            {
                LayoutUpdated += ExecuteScrollWhenLayoutUpdated;
            }
        }
        /// <inheritdoc/>
        protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
        {
            // Remove any existing events present if the control was previously loaded then unloaded
            ConnectEvents(false);

            AccentDec1Border = e.NameScope.Find <Border>(nameof(AccentDec1Border));
            AccentDec2Border = e.NameScope.Find <Border>(nameof(AccentDec2Border));
            AccentInc1Border = e.NameScope.Find <Border>(nameof(AccentInc1Border));
            AccentInc2Border = e.NameScope.Find <Border>(nameof(AccentInc2Border));

            // Must connect after controls are found
            ConnectEvents(true);

            base.OnApplyTemplate(e);
        }
Пример #8
0
        /// <inheritdoc/>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            if (Parent?.TemplatedParent != null)
            {
                if (_presenterSubscription != null)
                {
                    _presenterSubscription.Dispose();
                    _presenterSubscription = null;
                }

                Presenter?.ApplyTemplate();
                Presenter?.GetObservable(ContentPresenter.ChildProperty)
                .Subscribe(SetTemplatedParentAndApplyChildTemplates);
            }
        }
Пример #9
0
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     HeaderPresenter = e.NameScope.Find <ContentPresenter>("PART_HeaderPresenter");
     base.OnTemplateApplied(e);
 }
Пример #10
0
		protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
		{
			titleBar = e.NameScope.Find<Grid>("titlebar");
			minimiseButton = e.NameScope.Find<Button>("minimiseButton");
			restoreButton = e.NameScope.Find<Button>("restoreButton");
			closeButton = e.NameScope.Find<Button>("closeButton");
			icon = e.NameScope.Find<Image>("icon");

			topHorizontalGrip = e.NameScope.Find<Grid>("topHorizontalGrip");
			bottomHorizontalGrip = e.NameScope.Find<Grid>("bottomHorizontalGrip");
			leftVerticalGrip = e.NameScope.Find<Grid>("leftVerticalGrip");
			rightVerticalGrip = e.NameScope.Find<Grid>("rightVerticalGrip");

			topLeftGrip = e.NameScope.Find<Grid>("topLeftGrip");
			bottomLeftGrip = e.NameScope.Find<Grid>("bottomLeftGrip");
			topRightGrip = e.NameScope.Find<Grid>("topRightGrip");
			bottomRightGrip = e.NameScope.Find<Grid>("bottomRightGrip");

			minimiseButton.Click += (sender, ee) => { WindowState = WindowState.Minimized; };

			restoreButton.Click += (sender, ee) => { ToggleWindowState(); };

			titleBar.DoubleTapped += (sender, ee) => { ToggleWindowState(); };

			closeButton.Click += (sender, ee) => { Application.Current.Exit(); };

			icon.DoubleTapped += (sender, ee) => { Close(); };
		}
Пример #11
0
        /// <inheritdoc/>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            _popup = e.NameScope.Get<Popup>("PART_Popup");
            _popup.DependencyResolver = DependencyResolver.Instance;
            _popup.Opened += PopupOpened;
            _popup.Closed += PopupClosed;
        }
Пример #12
0
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     base.OnTemplateApplied(e);
     Scroll = e.NameScope.Find<IScrollable>("PART_ScrollViewer");
 }
Пример #13
0
 /// <summary>
 /// Builds the visual tree for the
 /// <see cref="T:System.Windows.Controls.Primitives.CalendarButton" />
 /// when a new template is applied.
 /// </summary>
 protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
 {
     SetPseudoClasses();
 }
Пример #14
0
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     _indicator = e.NameScope.Get<Border>("PART_Indicator");
     UpdateIndicator(Bounds.Size);
 }
Пример #15
0
        /// <inheritdoc/>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            if (_popup != null)
            {
                _popup.Opened -= PopupOpened;
            }

            _popup = e.NameScope.Get<Popup>("PART_Popup");
            _popup.Opened += PopupOpened;
        }
Пример #16
0
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     HeaderPresenter = e.NameScope.Find<ContentPresenter>("PART_HeaderPresenter");
     base.OnTemplateApplied(e);
 }
Пример #17
0
 /// <summary>
 /// Called when the control's template is applied.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     RaiseEvent(e);
 }
Пример #18
0
 /// <summary>
 /// Called when the control's template is applied.
 /// </summary>
 /// <param name="e">The event args.</param>
 protected virtual void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     RaiseEvent(e);
 }
Пример #19
0
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     base.OnTemplateApplied(e);
     OnTemplateAppliedCalled = true;
 }
Пример #20
0
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            TabStrip = e.NameScope.Find<IControl>("PART_TabStrip");
            Pages = e.NameScope.Find<IControl>("PART_Content");
        }
Пример #21
0
 /// <summary>
 /// Builds the visual tree for the
 /// <see cref="T:System.Windows.Controls.Primitives.CalendarButton" />
 /// when a new template is applied.
 /// </summary>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     base.OnTemplateApplied(e);
     SetPseudoClasses();
 }
Пример #22
0
        /// <inheritdoc/>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            if (Parent.TemplatedParent != null)
            {
                if (_presenterSubscription != null)
                {
                    _presenterSubscription.Dispose();
                    _presenterSubscription = null;
                }

                Presenter?.ApplyTemplate();
                Presenter?.GetObservable(ContentPresenter.ChildProperty)
                    .Subscribe(SetTemplatedParentAndApplyChildTemplates);
            }
        }
Пример #23
0
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            TextView = e.NameScope.Find<TextView>("textView");

            LogicalChildren.Add(TextView);

            disposables.Add(TextDocumentProperty.Changed.Subscribe(args =>
            {
                if (args.NewValue != null)
                {
                    // Todo unsubscribe these events.                 
                    TextDocument.Changing += (sender, ee) =>
                    {
                        TextDocument?.UndoStack.PushOptional(new RestoreCaretAndSelectionUndoAction(this));

                        if (BeforeTextChangedCommand != null)
                        {
                            BeforeTextChangedCommand.Execute(null);
                        }
                    };

                    TextDocument.Changed += (sender, ee) =>
                    {
                        InvalidateVisual();

                        LineHeight = TextView.CharSize.Height;

                        if (TextChangedCommand != null && TextChangedCommand.CanExecute(null))
                        {
                            TextChangedCommand.Execute(null);
                        }
                    };
                }
            }));
        }
Пример #24
0
        /// <summary>
        /// Builds the visual tree for the LayoutTransformerControl when a new
        /// template is applied.
        /// </summary>
        protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
        {
            base.OnTemplateApplied(e);

            _matrixTransform = new MatrixTransform();

            if (null != TransformRoot)
            {
                TransformRoot.RenderTransform = _matrixTransform;
                TransformRoot.RenderTransformOrigin = new RelativePoint(0, 0, RelativeUnit.Absolute);
            }

            ApplyLayoutTransform();
        }
Пример #25
0
 protected virtual void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
 }
Пример #26
0
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     _track = e.NameScope.Get<Track>("PART_Track");
 }