Example #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;
 }
Example #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();
            }
        }
Example #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;
                }
            }
        }
Example #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;
            }
        }
Example #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);
        }
Example #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);
            }
        }
Example #9
0
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     HeaderPresenter = e.NameScope.Find <ContentPresenter>("PART_HeaderPresenter");
     base.OnTemplateApplied(e);
 }
Example #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(); };
		}
Example #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;
        }
Example #12
0
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     base.OnTemplateApplied(e);
     Scroll = e.NameScope.Find<IScrollable>("PART_ScrollViewer");
 }
Example #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();
 }
Example #14
0
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     _indicator = e.NameScope.Get<Border>("PART_Indicator");
     UpdateIndicator(Bounds.Size);
 }
Example #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;
        }
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     HeaderPresenter = e.NameScope.Find<ContentPresenter>("PART_HeaderPresenter");
     base.OnTemplateApplied(e);
 }
Example #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);
 }
Example #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);
 }
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     base.OnTemplateApplied(e);
     OnTemplateAppliedCalled = true;
 }
Example #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");
        }
Example #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();
 }
Example #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);
            }
        }
Example #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);
                        }
                    };
                }
            }));
        }
        /// <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();
        }
Example #25
0
 protected virtual void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
 }
Example #26
0
 /// <inheritdoc/>
 protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
 {
     _track = e.NameScope.Get<Track>("PART_Track");
 }