System.Windows.FrameworkElement.OnApplyTemplate()

Here are the examples of the csharp api System.Windows.FrameworkElement.OnApplyTemplate() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

531 Examples 7

19 Source : BreadcrumbControl.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            int i = 0;
        }

19 Source : EndlessItemsControl.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _scrollViewer = (ScrollViewer)GetTemplateChild("PART_ScrollViewer");

            var listener = new PropertyChangeNotifier();
            listener.PropertyChanged += (_, __) =>
            {
                var offset = _scrollViewer.VerticalOffset;
                var height = _scrollViewer.ScrollableHeight;

                if (offset >= height && _allItems != null && _allItems.Count > 0)
                {
                    AddMoreItems(); 
                }
            };

            var binding = new Binding("VerticalOffset") { Source = _scrollViewer };
            listener.Attach(_scrollViewer, binding);
        }

19 Source : Tile.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _mainContent = (ContentPresenter)GetTemplateChild("PART_MainContent");
            _detailsContent = (ContentPresenter)GetTemplateChild("PART_DetailsContent");

            _tooltipIn = (Storyboard)GetTemplateChild("TooltipIn");
            _tooltipOut = (Storyboard)GetTemplateChild("TooltipOut");
        }

19 Source : CustomListBoxItem.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var isGroup = (bool)this.GetValue(IsGroupProperty);
            UpdateGroupState(isGroup);
        }

19 Source : IndeterminateProgressBar.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _root = (FrameworkElement) GetTemplateChild("Root");
            for (int i = 0; i < 5; i++)
            {
                var rect = (Rectangle) GetTemplateChild(string.Format("R{0}", i + 1));
                _rects.Add(rect);
            }

            if (_storyboard != null)
            {
                SetUpAnimations();
            }

            _templateApplied = true;
            UpdateBusyState(IsBusy);
        }

19 Source : CollapsableGridSplitter.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _elementHorizontalGridSplitterButton = GetTemplateChild(ELEMENT_HORIZONTAL_HANDLE_NAME) as ToggleButton;
            _elementVerticalGridSplitterButton = GetTemplateChild(ELEMENT_VERTICAL_HANDLE_NAME) as ToggleButton;
            _elementGridSplitterBackground = GetTemplateChild(ELEMENT_GRIDSPLITTER_BACKGROUND) as Rectangle;

            // Wire up the Checked and Unchecked events of the HorizontalGridSplitterHandle.
            if (_elementHorizontalGridSplitterButton != null)
            {
                _elementHorizontalGridSplitterButton.Checked += new RoutedEventHandler(GridSplitterButton_Checked);
                _elementHorizontalGridSplitterButton.Unchecked += new RoutedEventHandler(GridSplitterButton_Unchecked);
            }

            // Wire up the Checked and Unchecked events of the VerticalGridSplitterHandle.
            if (_elementVerticalGridSplitterButton != null)
            {
                _elementVerticalGridSplitterButton.Checked += new RoutedEventHandler(GridSplitterButton_Checked);
                _elementVerticalGridSplitterButton.Unchecked += new RoutedEventHandler(GridSplitterButton_Unchecked);
            }

            // Set default direction since we don't have all the components layed out yet.
            _gridCollapseDirection = GridCollapseDirection.Auto;

            // Directely call these events so design-time view updates appropriately
            OnCollapseModeChanged(CollapseMode);
            OnIsCollapsedChanged(IsCollapsed);
        }

19 Source : FlyoutMenuButton.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup = GetTemplateChild("PART_Popup") as Popup;
            _border = GetTemplateChild("PART_Border") as Border;
            _root = GetTemplateChild("RootElement") as Grid;
            _callout = GetTemplateChild("Callout") as Callout;

            _popup.Placement = PlacementMode.Custom;
            _popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(placePopup);

            if (_root == null) return;
            _fadeStoryboard = ((Storyboard)_root.TryFindResource("FadeBorderAnimation"));

            if (_border == null || _callout == null || _popup == null) return;

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                _popup.Visibility = Visibility.Visible;
            }

            _border.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
                if (!_popup.IsOpen)
                {
                    _popup.IsOpen = true;
                    _fadeStoryboard.Begin();
                }
            };

            _border.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.IsOpen = false;
                    _fadeStoryboard.Stop();
                }).After(200).Go();
            };

            _callout.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
            };

            _callout.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.IsOpen = false;
                    _fadeStoryboard.Stop();
                }).After(200).Go();
            };
        }

19 Source : FlyoutMenuToggleButton.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup = GetTemplateChild("PART_Popup") as Popup;
            _border = GetTemplateChild("PART_Border") as Border;
            _root = GetTemplateChild("RootElement") as Grid;
            _callout = GetTemplateChild("Callout") as Callout;

            _popup.Placement = PlacementMode.Custom;
            _popup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(placePopup);

            if (_root == null) return;
            _fadeStoryboard = ((Storyboard)_root.TryFindResource("FadeBorderAnimation"));

            if (_border == null || _callout == null || _popup == null) return;

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                _popup.IsOpen = true;
            }

            MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.IsOpen = false;
                }).After(200).Go();
            };
            MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
                if (!_popup.IsOpen)
                {
                    _popup.IsOpen = true;
                }
            };

            _callout.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
            };

            _callout.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.IsOpen = false;
                }).After(200).Go();
            };
        }

19 Source : CoverFlowControl.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _itemsPresenter = (ItemsPresenter)GetTemplateChild("ItemsPresenter");
        }

19 Source : SciChartInteractionToolbar.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _toolBarWrapPanel = GetTemplateChild("PART_Container") as WrapPanel;

            AddExtraContent();

        }

19 Source : SciChart3DInteractionToolbar.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _toolBarWrapPanel = GetTemplateChild("PART_Container") as WrapPanel;

            AddExtraContent();
        }

19 Source : CoverFlowItemControl.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            
            _container = (Border)GetTemplateChild("container");

            _rotationKeyFrame = (EasingDoubleKeyFrame)GetTemplateChild("rotationKeyFrame");
            _scaleXKeyFrame = (EasingDoubleKeyFrame)GetTemplateChild("scaleXKeyFrame");
            _scaleYKeyFrame = (EasingDoubleKeyFrame)GetTemplateChild("scaleYKeyFrame");
            _scaleTransform = (ScaleTransform)GetTemplateChild("scaleTransform");
            
            _planeProjection = (PlaneProjector)GetTemplateChild("Rotator");

            if (_planeProjection != null)
            {
                _planeProjection.RotationY = _yRotation;
                
                if (_container != null)
                {
                    SubscribeContentPresenterEvents(_container);
                }
            }

            _animation = (Storyboard)GetTemplateChild("Animation");
            _selectionAnimation = (ColorAnimation)GetTemplateChild("SelectionColorAnimation");

            if (_selectionAnimation != null)
            {
                _selectionAnimation.To = _selectionColor;
            }

            if (_animation != null)
            {
                SubscribeAnimationEvents(_animation);

                _xAnimation = new DoubleAnimation();
                _animation.Children.Add(_xAnimation);

                Storyboard.SetTarget(_xAnimation, this);
                Storyboard.SetTargetProperty(_xAnimation, new PropertyPath("(Canvas.Left)"));
            }

            UpdateVisualState("MouseLeave", true);
        }

19 Source : FlyoutMenuButton.cs
with MIT License
from ABTSoftware

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup = GetTemplateChild("PART_Popup") as Canvas;
            _border = GetTemplateChild("PART_Border") as Border;
            _root = GetTemplateChild("RootElement") as Grid;
            _callout = GetTemplateChild("Callout") as Callout;

            if (_root == null) return;
            _fadeStoryboard = ((Storyboard)_root.TryFindResource("FadeBorderAnimation"));

            if (_border == null || _callout == null || _popup == null) return;

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                _popup.Visibility = Visibility.Visible;
            }

            _border.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
                if (_popup.Visibility == Visibility.Collapsed)
                {
                    _popup.Visibility = Visibility.Visible;
                    _fadeStoryboard.Begin();
                }
            };

            _border.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.Visibility = Visibility.Collapsed;
                    _fadeStoryboard.Stop();
                }).After(200).Go();
            };

            _callout.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
            };

            _callout.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.Visibility = Visibility.Collapsed;
                    _fadeStoryboard.Stop();
                }).After(200).Go();
            };

        }

19 Source : FabricSplitButton.cs
with MIT License
from adospace

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (GetTemplateChild("PART_ArrowDown") is FrameworkElement downArrowPart)
            {
                downArrowPart.PreviewMouseDown += DownArrowPart_PreviewMouseDown;       
            }

            PreviewMouseLeftButtonDown += FabricSplitButton_PreviewMouseLeftButtonDown;
        }

19 Source : Timeline.cs
with GNU General Public License v3.0
from AndreiFedarets

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            //------------------
            _itemsControl = GetTemplateChild(ItemsControlPartName) as ItemsControl;
            if (_itemsControl != null)
            {
                _itemsControl.ItemsSource = _collection;
            }
            //------------------
            _containerGrid = GetTemplateChild(ContainerGridPartName) as Grid;
            //------------------
            _scrollViewer = GetTemplateChild(ScrollViewerPartName) as ScrollViewer;
            //------------------
            _contentBorder = GetTemplateChild(ContentBorderPartName) as Border;
            InitializeChildren();
        }

19 Source : EventTreeItem.cs
with GNU General Public License v3.0
from AndreiFedarets

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            //------------------
            //_headerPanel = GetTemplateChild(HeaderPanelPartName) as Panel;
            //_contentPanel = GetTemplateChild(ContentPanelPartName) as Panel;
            //_footerPanel = GetTemplateChild(FooterPanelPartName) as Panel;
            double eventPercent = NativeEventHelper.GetEventPercent(_event);
            //------------------
            Border childrenIndicatorBorder = GetTemplateChild(ChildrenIndicatorBorderPartName) as Border;
            if (childrenIndicatorBorder != null)
            {
                childrenIndicatorBorder.Visibility = _event.HasChildren ? Visibility.Visible : Visibility.Hidden;
            }
            //------------------
            Border percentsColorIndicatorBorder = GetTemplateChild(PercentsColorIndicatorBorderPartName) as Border;
            if (percentsColorIndicatorBorder != null)
            {
                percentsColorIndicatorBorder.Visibility = IsRooreplacedem ? Visibility.Collapsed : Visibility.Visible;
                percentsColorIndicatorBorder.Background = new SolidColorBrush(PercentsToColorConverter.Convert(eventPercent));
            }
            //------------------
            TextBlock percentTextBlock = GetTemplateChild(PercentTextBlockPartName) as TextBlock;
            if (percentTextBlock != null)
            {
                percentTextBlock.Text = string.Format("{0}%", eventPercent);
            }
            //------------------
            TextBlock timeTextBlock = GetTemplateChild(TimeTextBlockPartName) as TextBlock;
            if (timeTextBlock != null)
            {
                timeTextBlock.Text = string.Format("{0}ms", _event.Time);
            }
            //------------------
            TextBlock hitsTextBlock = GetTemplateChild(HitsTextBlockPartName) as TextBlock;
            if (hitsTextBlock != null)
            {
                hitsTextBlock.Text = string.Format("{0}hits", _event.Hits);
            }
            //------------------
            TextBlock nameTextBlock = GetTemplateChild(NameTextBlockPartName) as TextBlock;
            if (nameTextBlock != null)
            {
                nameTextBlock.Text = EventText;
            }
            SynchronizeLevelOffset(LevelOffset);
        }

19 Source : ThreadTimeline.cs
with GNU General Public License v3.0
from AndreiFedarets

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            //------------------
            _itemsControl = GetTemplateChild(ItemsControlPartName) as ItemsControl;
            if (_itemsControl != null)
            {
                _itemsControl.ItemsSource = _collection;
            }
            //------------------
            _headerTextBlock = GetTemplateChild(HeaderTextBlockPartName) as TextBlock;
            if (_headerTextBlock != null)
            {
                _headerTextBlock.Text = string.Format("Thread {0}", _threadUid);
            }
            InitializeChildren();
        }

19 Source : ThreadTimelineItem.cs
with GNU General Public License v3.0
from AndreiFedarets

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            //------------------
            string eventName = _eventMessageBuilder.BuildMessage(EventTree);
            uint eventTime = EventTree.Time;
            ToolTip = string.Concat(eventName, Environment.NewLine, eventTime, "ms");
            //------------------
            double eventPercent = NativeEventHelper.GetEventPercent(eventTime, _minTime, _maxTime);
            Background = new SolidColorBrush(PercentsToColorConverter.Convert(eventPercent));
        }

19 Source : EventsTreeView.cs
with GNU General Public License v3.0
from AndreiFedarets

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            //------------------
            _itemsControl = GetTemplateChild(ItemsControlPartName) as ItemsControl;
            if (_itemsControl != null)
            {
                _itemsControl.ItemsSource = _board;
            }
            InitializeChildren();
        }

19 Source : CustomWindow.cs
with GNU General Public License v3.0
from AndreiFedarets

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            //MinimizeButton
            if (_minimizeButton != null)
            {
                _minimizeButton.Click -= OnMinimizeButtonClick;
            }
            _minimizeButton = GetTemplateChild(MinimizeButtonPartName) as Button;
            if (_minimizeButton != null)
            {
                _minimizeButton.Click += OnMinimizeButtonClick;
            }
            //RestoreButton
            if (_restoreButton != null)
            {
                _restoreButton.Click -= OnRestoreButtonClick;
            }
            _restoreButton = GetTemplateChild(RestoreButtonPartName) as Button;
            if (_restoreButton != null)
            {
                _restoreButton.Click += OnRestoreButtonClick;
            }
            //MaximizeButton
            if (_maximizeButton != null)
            {
                _maximizeButton.Click -= OnMaximizeButtonClick;
            }
            _maximizeButton = GetTemplateChild(MaximizeButtonPartName) as Button;
            if (_maximizeButton != null)
            {
                _maximizeButton.Click += OnMaximizeButtonClick;
            }
            //CloseButton
            if (_closeButton != null)
            {
                _closeButton.Click -= OnCloseButtonClick;
            }
            _closeButton = GetTemplateChild(CloseButtonPartName) as Button;
            if (_closeButton != null)
            {
                _closeButton.Click += OnCloseButtonClick;
            }

            SynchronizeWithWindowState();
            UpdateMaximizeButtonVisibility();
            UpdateMinimizeButtonVisibility();
        }

19 Source : VduControl.cs
with MIT License
from AntonyCorbett

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (GetTemplateChild("VolumeImage") is Image image)
            {
                _image = image;
            }

            if (GetTemplateChild("InnerBorder") is Border border)
            {
                _innerBorder = border;
            }
        }

19 Source : Magnifier.cs
with MIT License
from AntonyCorbett

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var newBrush = GetTemplateChild(PartVisualBrush) as VisualBrush ?? new VisualBrush();

            // Just create a brush as placeholder even if there is no such brush.
            // This avoids having to "if" each access to the _visualBrush member.
            // Do not keep the current _visualBrush whatsoever to avoid memory leaks.
            newBrush.Viewbox = _visualBrush.Viewbox;
            _visualBrush = newBrush;
        }

19 Source : ClockControl.cs
with MIT License
from AntonyCorbett

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            GetElementRefs();

            SetFlatOrNonFlatStyle();
            
            if (GetTemplateChild("ClockCanvas") is Canvas cc)
            {
                GenerateHourMarkers(cc);
                GenerateHourNumbers(cc);
            }
        }

19 Source : CountdownControl.cs
with MIT License
from AntonyCorbett

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (GetTemplateChild("CountdownCanvas") is Canvas canvas)
            {
                InitCanvas(canvas);
            }
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v2.0
from Asixa

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var accentBrush = TryFindResource("AccentColorBrush") as SolidColorBrush;
            accentBrush?.Color.CreateAccentColors();
        }

19 Source : ChildWindow.cs
with GNU General Public License v3.0
from atomex-me

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // really necessary?
            if (Template == null)
                return;

            var isActiveBindingAction = new Action(() => {
                var window = Window.GetWindow(this);
                if (window != null)
                    SetBinding(IsWindowHostActiveProperty, new Binding(nameof(Window.IsActive)) { Source = window, Mode = BindingMode.OneWay });
            });

            if (!IsLoaded)
            {
                this.BeginInvoke(isActiveBindingAction, DispatcherPriority.Loaded);
            }
            else
            {
                isActiveBindingAction();
            }

            _hideStoryboard = Template.FindName(HideStoryboard, this) as Storyboard;

            if (_partOverlay != null)          
                _partOverlay.MouseLeftButtonDown -= PartOverlayOnClose;


            _partOverlay = Template.FindName(PART_Overlay, this) as Grid;
            if (_partOverlay != null)
                _partOverlay.MouseLeftButtonDown += PartOverlayOnClose;

            _partWindow = Template.FindName(PART_Window, this) as Grid;
            if (_partWindow != null)
                _partWindow.RenderTransform = _moveTransform;

            _icon = Template.FindName(PART_Icon, this) as ContentControl;

            if (_headerThumb != null)
                _headerThumb.DragDelta -= HeaderThumbDragDelta;

            _headerThumb = Template.FindName(PART_HeaderThumb, this) as IMetroThumb;
            if (_headerThumb != null && _partWindow != null)
                _headerThumb.DragDelta += HeaderThumbDragDelta;

            if (_closeButton != null)
                _closeButton.Click -= OnCloseButtonClick;

            _closeButton = Template.FindName(PART_CloseButton, this) as Button;
            if (_closeButton != null)
                _closeButton.Click += OnCloseButtonClick;
        }

19 Source : DelcamDesktop.cs
with MIT License
from Autodesk

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var objHomeButton = (Button) GetTemplateChild(PART_HomeButton);
            if (objHomeButton != null)
            {
                objHomeButton.Click += HomeButton_Click;
            }

            Button objSaveButton = (Button) GetTemplateChild(PART_SaveButton);
            if (objSaveButton != null)
            {
                objSaveButton.Click += SaveButton_Click;
            }

            Button objBackButton = (Button) GetTemplateChild(PART_BackButton);
            if (objBackButton != null)
            {
                objBackButton.Click += BackButton_Click;
            }

            Button objHelpButton = (Button) GetTemplateChild(PART_HelpButton);
            if (objHelpButton != null)
            {
                objHelpButton.Click += HelpButton_Click;
            }

            Button objAboutButton = (Button) GetTemplateChild(PART_AboutButton);
            if (objAboutButton != null)
            {
                objAboutButton.Click += AboutButton_Click;
            }

            Button objExitButton = (Button) GetTemplateChild(PART_ExitButton);
            if (objExitButton != null)
            {
                objExitButton.Click += ExitButton_Click;
            }

            if (objHomeButton != null)
            {
                // Bind the command for the home button to the exposed property
                Binding objHomeBinding = new Binding("HomeButtonCommand");
                objHomeBinding.Mode = BindingMode.OneWay;
                objHomeBinding.Source = this;
                objHomeButton.SetBinding(Button.CommandProperty, objHomeBinding);
            }

            if (objSaveButton != null)
            {
                // Bind the command for the back button to the exposed property
                Binding objSaveBinding = new Binding("SaveButtonCommand");
                objSaveBinding.Mode = BindingMode.OneWay;
                objSaveBinding.Source = this;
                objSaveButton.SetBinding(Button.CommandProperty, objSaveBinding);
            }

            if (objBackButton != null)
            {
                // Bind the command for the back button to the exposed property
                Binding objBackBinding = new Binding("BackButtonCommand");
                objBackBinding.Mode = BindingMode.OneWay;
                objBackBinding.Source = this;
                objBackButton.SetBinding(Button.CommandProperty, objBackBinding);
            }

            if (objAboutButton != null)
            {
                // Bind the command for the back button to the exposed property
                Binding objAboutBinding = new Binding("AboutButtonCommand");
                objAboutBinding.Mode = BindingMode.OneWay;
                objAboutBinding.Source = this;
                objAboutButton.SetBinding(Button.CommandProperty, objAboutBinding);
            }

            if (objHelpButton != null)
            {
                // Bind the command for the back button to the exposed property
                Binding objHelpBinding = new Binding("HelpButtonCommand");
                objHelpBinding.Mode = BindingMode.OneWay;
                objHelpBinding.Source = this;
                objHelpButton.SetBinding(Button.CommandProperty, objHelpBinding);
            }

            if (objExitButton != null)
            {
                // Bind the command for the back button to the exposed property
                Binding objExitBinding = new Binding("ExitButtonCommand");
                objExitBinding.Mode = BindingMode.OneWay;
                objExitBinding.Source = this;
                objExitButton.SetBinding(Button.CommandProperty, objExitBinding);
            }
        }

19 Source : DelcamLinkButton.cs
with MIT License
from Autodesk

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
        }

19 Source : DelcamNumericUpDown.cs
with MIT License
from Autodesk

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            //Bind the value TextBox's Text property to the Value property of the control
            TextBox objValue = (TextBox) GetTemplateChild(PART_Value);
            if (objValue != null)
            {
                objValue.PreviewKeyDown += ValidateKeyDown;
            }
        }

19 Source : DelcamFlowControl.cs
with MIT License
from Autodesk

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            UpdateDisplay();

            Slider objSlider = (Slider) GetTemplateChild(PART_Slider);
            if (objSlider != null)
            {
                objSlider.Minimum = 0;
                Binding objMaxBinding = new Binding("Items.Count");
                objMaxBinding.Mode = BindingMode.OneWay;
                objMaxBinding.Source = this;
                objMaxBinding.Converter = new ItemsMaxConverter();
                objSlider.SetBinding(Slider.MaximumProperty, objMaxBinding);
                Binding objValueBinding = new Binding("SelectedIndex");
                objValueBinding.Source = this;
                objSlider.SetBinding(Slider.ValueProperty, objValueBinding);
            }
        }

19 Source : AyTableViewCellsPresenter.cs
with MIT License
from ay2015

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            ccDetail = GetTemplateChild("detailContent") as ContentPresenter;
        }

19 Source : AyTableViewRowsPresenter.cs
with MIT License
from ay2015

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.ItemsSource = ParentTableView.ItemsSource;
            ParentTableView.ContentScollViewer = GetTemplateChild("PART_ScrollViewer") as ScrollViewer;
        }

19 Source : AyTableViewColumnHeader.cs
with MIT License
from ay2015

public override void OnApplyTemplate()
        {
            var col = this.Content as AyTableViewColumn;
            if (col != null)
            {
                this.ContentTemplate = col.replacedleTemplate;
                this.ContentStringFormat = col.ContentStringFormat;
                this.HorizontalContentAlignment = col.HorizontalAlignment;
                this.CellContentStringFormat = col.CellContentStringFormat;//2018-2-22 17:18:12增加
                this.VerticalContentAlignment = col.VerticalAlignment;
                this.ContentMargin = col.HeaderMargin;
                this.ResizeColumn = col.ResizeColumn;
                if (col.ParentTableView.IsNotNull())
                {
                    if (col.ParentTableView.HasIndexColumn && col.Field.ToObjectString() == "AYID")
                    {
                        this.ColumnHeight = col.ParentTableView.HeaderHeight;
                    }
                    else if (col.ParentTableView.HasCheckBoxColumn && col.Field.ToObjectString() == "AYCHECK")
                    {
                        this.ColumnHeight = col.ParentTableView.HeaderHeight;
                    }
                    else
                    {
                        this.ColumnHeight = col.RowSpan * (col.ParentTableView.HeaderHeight / col.ParentTableView.HeadRowCount);
                    }
                    if (Column.ParentTableView.OrderBySupport)
                    {
                        CurrentSort = Column.SortDirection;
                        this.Click += AyTableViewColumnHeader_Click;
                        this.Unloaded += AyTableViewColumnHeader_Unloaded;
                    }
                }


            }


            base.OnApplyTemplate();
        }

19 Source : CirclePointRingLoading.cs
with MIT License
from ay2015

public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			UpdateLargeState();
			UpdateActiveState();
		}

19 Source : AySplitView.cs
with MIT License
from ay2015

public override void OnApplyTemplate()
        {
            if (!WpfTreeHelper.IsInDesignMode)
            {
                LeftArea = Template.FindName("LeftArea", this) as Grid;
                ContentArea = Template.FindName("ContentArea", this) as Grid;
                colLeft = Template.FindName("colLeft", this) as ColumnDefinition;
                colContent = Template.FindName("colContent", this) as ColumnDefinition;
                rowTop = Template.FindName("rowTop", this) as RowDefinition;
                rowBottom = Template.FindName("rowBottom", this) as RowDefinition;
                cc = Template.FindName("cc", this) as ContentControl;
            }

            base.OnApplyTemplate();
        }

19 Source : AyTableViewCell.cs
with MIT License
from ay2015

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            bd = GetTemplateChild("SelectTen") as Border;


            ContentPresenter cp = GetTemplateChild("contentPresenter") as ContentPresenter;
            _EditContent = GetTemplateChild("contentPresenter1") as ContentPresenter;
 
                if (_column.IsNotNull() && _column.Formatter.IsNotNull())
                {
                    var _b = BindingOperations.GetBinding(cp, ContentPresenter.ContentProperty);
                    Binding newbind = new Binding { Converter = _column.Formatter, Path = _b.Path, Mode = _b.Mode, RelativeSource = _b.RelativeSource };
                    BindingOperations.ClearBinding(cp, ContentPresenter.ContentProperty);
                    BindingOperations.SetBinding(cp, ContentPresenter.ContentProperty, newbind);
                }
                cp.ApplyTemplate();
                tb = WpfTreeHelper.FindChild<AyText>(cp);
                if (tb.IsNotNull())
                {
                    tb.TextWrapping = CellTextWrapping;

                    if (CellCharacterEllipsis == TextTrimming.CharacterEllipsis)
                    {
                        ToolTip tt = new System.Windows.Controls.ToolTip();
                        AyText ttb = new AyText();
                        ttb.SetBinding(AyText.TextProperty, new Binding { Source = cp.Content });
                        tt.Content = ttb;
                        tb.ToolTip = tt;
                        if (dpd != null)
                        {
                            dpd.AddValueChanged(tb, ActualWidthPropertyChangedHandler);
                        }
                        if (tb.ActualWidth < tb.DesiredSize.Width)
                            tt.Visibility = Visibility.Visible;
                        else
                            tt.Visibility = Visibility.Collapsed;
                    }
                    tb.TextTrimming = CellCharacterEllipsis;
                
            }



        }

19 Source : AyPath.cs
with MIT License
from ay2015

public override void OnApplyTemplate()
        {
            UpdatePathData();
            base.OnApplyTemplate();

        }

19 Source : Explorer.cs
with MIT License
from Bassman2

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            TreeView treeView = GetTemplateChild("treeView") as TreeView;
            treeView.SelectedItemChanged += OnSelectedFolderChanged;

            DataGrid dataGrid = GetTemplateChild("dataGrid") as DataGrid;
            dataGrid.PreviewDragEnter += OnDrag;
            dataGrid.PreviewDragOver += OnDrag;
            dataGrid.PreviewDrop += OnDrop;
            dataGrid.PreviewMouseLeftButtonDown += OnMouseDown;
            dataGrid.PreviewMouseLeftButtonUp += OnMouseUp;
            dataGrid.PreviewMouseMove += OnMouseMove;
            dataGrid.MouseDoubleClick += OnMouseDoubleClick;
            dataGrid.SelectionChanged += OnSelectionChanged;
            dataGrid.Sorting += OnSorting;

            //ProgresshWindow dlg = new ProgresshWindow();
            //dlg.Show();
        }

19 Source : DropDownButton.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.clickButton = this.EnforceInstance<Button>("PART_Button");
            this.menu = this.EnforceInstance<ContextMenu>("PART_Menu");
            this.InitializeVisualElementsContainer();
            if (this.menu != null && this.Items != null && this.ItemsSource == null)
            {
                foreach (var newItem in this.Items)
                {
                    this.TryRemoveVisualFromOldTree(newItem);
                    this.menu.Items.Add(newItem);
                }
            }
        }

19 Source : SplitButton.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this._clickButton = this.EnforceInstance<Button>("PART_Button");
            this._expander = this.EnforceInstance<Button>("PART_Expander");
            this._listBox = this.EnforceInstance<ListBox>("PART_ListBox");
            this._popup = this.EnforceInstance<Popup>("PART_Popup");
            this.InitializeVisualElementsContainer();
            if (this._listBox != null && this.Items != null && this.ItemsSource == null)
            {
                foreach (var newItem in this.Items)
                {
                    this.TryRemoveVisualFromOldTree(newItem);
                    this._listBox.Items.Add(newItem);
                }
            }
        }

19 Source : TransitioningContentControl.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            if (this.IsTransitioning)
            {
                this.AbortTransition();
            }

            if (this.CustomVisualStates != null && this.CustomVisualStates.Any())
            {
                var presentationGroup = VisualStates.TryGetVisualStateGroup(this, PresentationGroup);
                if (presentationGroup != null)
                {
                    foreach (var state in this.CustomVisualStates)
                    {
                        presentationGroup.States.Add(state);
                    }
                }
            }

            base.OnApplyTemplate();

            this.previousContentPresentationSite = this.GetTemplateChild(PreviousContentPresentationSitePartName) as ContentPresenter;
            this.currentContentPresentationSite = this.GetTemplateChild(CurrentContentPresentationSitePartName) as ContentPresenter;

            if (this.currentContentPresentationSite != null)
            {
                if (this.ContentTemplateSelector != null)
                {
                    this.currentContentPresentationSite.ContentTemplate = this.ContentTemplateSelector.SelectTemplate(this.Content, this);
                }
                else
                {
                    this.currentContentPresentationSite.ContentTemplate = this.ContentTemplate;
                }
                this.currentContentPresentationSite.Content = this.Content;
            }

            // hookup currenttransition
            Storyboard transition = this.GetStoryboard(this.Transition);
            this.CurrentTransition = transition;
            if (transition == null)
            {
                var invalidTransition = this.Transition;
                // revert to default
                this.Transition = DefaultTransitionState;

                throw new ArgumentException(string.Format("'{0}' Transition could not be found!", invalidTransition), "Transition");
            }
            VisualStateManager.GoToState(this, NormalState, false);
        }

19 Source : PackIconBase.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            UpdateData();
        }

19 Source : TimePickerBase.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            UnSubscribeEvents();

            _popup = GetTemplateChild(ElementPopup) as Popup;
            _button = GetTemplateChild(ElementButton) as Button;
            _hourInput = GetTemplateChild(ElementHourPicker) as Selector;
            _minuteInput = GetTemplateChild(ElementMinutePicker) as Selector;
            _secondInput = GetTemplateChild(ElementSecondPicker) as Selector;
            _hourHand = GetTemplateChild(ElementHourHand) as FrameworkElement;
            _ampmSwitcher = GetTemplateChild(ElementAmPmSwitcher) as Selector;
            _minuteHand = GetTemplateChild(ElementMinuteHand) as FrameworkElement;
            _secondHand = GetTemplateChild(ElementSecondHand) as FrameworkElement;
            _textBox = GetTemplateChild(ElementTextBox) as DatePickerTextBox;

            SetHandVisibility(HandVisibility);
            SetPickerVisibility(PickerVisibility);

            SetHourPartValues(SelectedTime.GetValueOrDefault());
            WriteValueToTextBox();

            SetDefaultTimeOfDayValues();
            SubscribeEvents();
            ApplyCulture();
            ApplyBindings();

        }

19 Source : FlipView.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.showBannerStoryboard = ((Storyboard)this.Template.Resources["ShowBannerStoryboard"]).Clone();
            this.hideBannerStoryboard = ((Storyboard)this.Template.Resources["HideBannerStoryboard"]).Clone();

            this.showControlStoryboard = ((Storyboard)this.Template.Resources["ShowControlStoryboard"]).Clone();
            this.hideControlStoryboard = ((Storyboard)this.Template.Resources["HideControlStoryboard"]).Clone();

            this.presenter = this.GetTemplateChild(PART_Presenter) as TransitioningContentControl;

            if (this.forwardButton != null)
            {
                this.forwardButton.Click -= this.NextButtonClick;
            }
            if (this.backButton != null)
            {
                this.backButton.Click -= this.PrevButtonClick;
            }
            if (this.upButton != null)
            {
                this.upButton.Click -= this.PrevButtonClick;
            }
            if (this.downButton != null)
            {
                this.downButton.Click -= this.NextButtonClick;
            }

            this.forwardButton = this.GetTemplateChild(PART_ForwardButton) as Button;
            this.backButton = this.GetTemplateChild(PART_BackButton) as Button;
            this.upButton = this.GetTemplateChild(PART_UpButton) as Button;
            this.downButton = this.GetTemplateChild(PART_DownButton) as Button;

            this.bannerGrid = this.GetTemplateChild(PART_BannerGrid) as Grid;
            this.bannerLabel = this.GetTemplateChild(PART_BannerLabel) as Label;

            if (this.forwardButton != null)
            {
                this.forwardButton.Click += this.NextButtonClick;
            }
            if (this.backButton != null)
            {
                this.backButton.Click += this.PrevButtonClick;
            }
            if (this.upButton != null)
            {
                this.upButton.Click += this.PrevButtonClick;
            }
            if (this.downButton != null)
            {
                this.downButton.Click += this.NextButtonClick;
            }

            if (this.bannerLabel != null)
            {
                this.bannerLabel.Opacity = this.IsBannerEnabled ? 1d : 0d;
            }
        }

19 Source : NumericUpDown.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _repeatUp = GetTemplateChild(ElementNumericUp) as RepeatButton;
            _repeatDown = GetTemplateChild(ElementNumericDown) as RepeatButton;
            
            _valueTextBox = GetTemplateChild(ElementTextBox) as TextBox;

            if (_repeatUp == null ||
                _repeatDown == null ||
                _valueTextBox == null)
            {
                throw new InvalidOperationException(string.Format("You have missed to specify {0}, {1} or {2} in your template", ElementNumericUp, ElementNumericDown, ElementTextBox));
            }

            this.ToggleReadOnlyMode(this.IsReadOnly | !this.InterceptManualEnter);

            _repeatUp.Click += (o, e) => ChangeValueWithSpeedUp(true);
            _repeatDown.Click += (o, e) => ChangeValueWithSpeedUp(false);

            _repeatUp.PreviewMouseUp += (o, e) => ResetInternal();
            _repeatDown.PreviewMouseUp += (o, e) => ResetInternal();
            
            OnValueChanged(Value, Value);

            _scrollViewer = TryFindScrollViewer();
        }

19 Source : HamburgerMenu.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            if (_hamburgerButton != null)
            {
                _hamburgerButton.Click -= HamburgerButton_Click;
            }

            if (_buttonsListView != null)
            {
                _buttonsListView.MouseUp -= ButtonsListView_ItemClick;
                _buttonsListView.SelectionChanged -= ButtonsListView_SelectionChanged;
            }

            if (_optionsListView != null)
            {
                _optionsListView.MouseUp -= OptionsListView_ItemClick;
                _optionsListView.SelectionChanged -= OptionsListView_SelectionChanged;
            }

            _hamburgerButton = (Button)GetTemplateChild("HamburgerButton");
            _buttonsListView = (ListBox)GetTemplateChild("ButtonsListView");
            _optionsListView = (ListBox)GetTemplateChild("OptionsListView");

            if (_hamburgerButton != null)
            {
                _hamburgerButton.Click += HamburgerButton_Click;
            }

            if (_buttonsListView != null)
            {
                _buttonsListView.MouseUp += ButtonsListView_ItemClick;
                _buttonsListView.SelectionChanged += ButtonsListView_SelectionChanged;
            }

            if (_optionsListView != null)
            {
                _optionsListView.MouseUp += OptionsListView_ItemClick;
                _optionsListView.SelectionChanged += OptionsListView_SelectionChanged;
            }

            ChangeItemFocusVisualStyle();

            Loaded -= HamburgerMenu_Loaded;
            Loaded += HamburgerMenu_Loaded;

            base.OnApplyTemplate();
        }

19 Source : SplitView.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.paneClipRectangle = this.GetTemplateChild("PaneClipRectangle") as RectangleGeometry;

            this.lightDismissLayer = this.GetTemplateChild("LightDismissLayer") as Rectangle;
            if (this.lightDismissLayer != null)
            {
                this.lightDismissLayer.MouseDown += this.OnLightDismiss;
            }
        }

19 Source : Flyout.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.flyoutRoot = this.GetTemplateChild("PART_Root") as FrameworkElement;
            if (this.flyoutRoot == null)
            {
                return;
            }

            this.flyoutHeader = this.GetTemplateChild("PART_Header") as FrameworkElement;
            this.flyoutHeader?.ApplyTemplate();
            this.flyoutContent = this.GetTemplateChild("PART_Content") as FrameworkElement;

            var thumbContentControl = this.flyoutHeader as IMetroThumb;
            if (thumbContentControl != null)
            {
                thumbContentControl.DragStarted -= this.WindowreplacedleThumbOnDragStarted;
                thumbContentControl.DragCompleted -= this.WindowreplacedleThumbOnDragCompleted;
                thumbContentControl.PreviewMouseLeftButtonUp -= this.WindowreplacedleThumbOnPreviewMouseLeftButtonUp;
                thumbContentControl.DragDelta -= this.WindowreplacedleThumbMoveOnDragDelta;
                thumbContentControl.MouseDoubleClick -= this.WindowreplacedleThumbChangeWindowStateOnMouseDoubleClick;
                thumbContentControl.MouseRightButtonUp -= this.WindowreplacedleThumbSystemMenuOnMouseRightButtonUp;

                var flyoutsControl = this.TryFindParent<FlyoutsControl>();
                if (flyoutsControl != null)
                {
                    thumbContentControl.DragStarted += this.WindowreplacedleThumbOnDragStarted;
                    thumbContentControl.DragCompleted += this.WindowreplacedleThumbOnDragCompleted;
                    thumbContentControl.PreviewMouseLeftButtonUp += this.WindowreplacedleThumbOnPreviewMouseLeftButtonUp;
                    thumbContentControl.DragDelta += this.WindowreplacedleThumbMoveOnDragDelta;
                    thumbContentControl.MouseDoubleClick += this.WindowreplacedleThumbChangeWindowStateOnMouseDoubleClick;
                    thumbContentControl.MouseRightButtonUp += this.WindowreplacedleThumbSystemMenuOnMouseRightButtonUp;
                }
            }

            this.hideStoryboard = this.GetTemplateChild("HideStoryboard") as Storyboard;
            this.hideFrame = this.GetTemplateChild("hideFrame") as SplineDoubleKeyFrame;
            this.hideFrameY = this.GetTemplateChild("hideFrameY") as SplineDoubleKeyFrame;
            this.showFrame = this.GetTemplateChild("showFrame") as SplineDoubleKeyFrame;
            this.showFrameY = this.GetTemplateChild("showFrameY") as SplineDoubleKeyFrame;
            this.fadeOutFrame = this.GetTemplateChild("fadeOutFrame") as SplineDoubleKeyFrame;

            if (this.hideFrame == null || this.showFrame == null || this.hideFrameY == null || this.showFrameY == null || this.fadeOutFrame == null)
            {
                return;
            }

            this.ApplyAnimation(this.Position, this.AnimateOpacity);
        }

19 Source : GlowWindow.xaml.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.OpacityStoryboard = this.TryFindResource("OpacityStoryboard") as Storyboard;
        }

19 Source : ToggleSwitchButton.cs
with Apache License 2.0
from beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _BackgroundTranslate = GetTemplateChild(PART_BackgroundTranslate) as TranslateTransform;
            _DraggingThumb = GetTemplateChild(PART_DraggingThumb) as Thumb;
            _SwitchTrack = GetTemplateChild(PART_SwitchTrack) as Grid;
            _ThumbIndicator = GetTemplateChild(PART_ThumbIndicator) as FrameworkElement;
            _ThumbTranslate = GetTemplateChild(PART_ThumbTranslate) as TranslateTransform;

            if (_ThumbIndicator != null && _ThumbTranslate != null && _BackgroundTranslate != null)
            {
                Binding translationBinding;
                translationBinding = new System.Windows.Data.Binding("X");
                translationBinding.Source = _ThumbTranslate;
                BindingOperations.SetBinding(_BackgroundTranslate, TranslateTransform.XProperty, translationBinding);
            }

            if (_DraggingThumb != null && _ThumbIndicator != null && _ThumbTranslate != null)
            {
                _DraggingThumb.DragStarted -= _DraggingThumb_DragStarted;
                _DraggingThumb.DragDelta -= _DraggingThumb_DragDelta;
                _DraggingThumb.DragCompleted -= _DraggingThumb_DragCompleted;
                _DraggingThumb.DragStarted += _DraggingThumb_DragStarted;
                _DraggingThumb.DragDelta += _DraggingThumb_DragDelta;
                _DraggingThumb.DragCompleted += _DraggingThumb_DragCompleted;
                if (_SwitchTrack != null)
                {
                    _SwitchTrack.SizeChanged -= _SwitchTrack_SizeChanged;
                    _SwitchTrack.SizeChanged += _SwitchTrack_SizeChanged;
                }
            }
        }

See More Examples