Example #1
0
        private void BaseObject_Loaded(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Base Object Loaded");
            if (this.Template != null)
            {
                ContentPresenter contentPresenter =
                    this.Template.FindName("PART_ContentPresenter", this) as ContentPresenter;

                MoveThumb thumb =
                    this.Template.FindName("PART_MoveThumb", this) as MoveThumb;

                if (contentPresenter != null && thumb != null)
                {
                    UIElement contentVisual =
                        VisualTreeHelper.GetChild(contentPresenter, 0) as UIElement;

                    if (contentVisual != null)
                    {
                        ControlTemplate template =
                            BaseObject.GetMoveThumbTemplate(contentVisual) as ControlTemplate;

                        if (template != null)
                        {
                            thumb.Template = template;
                        }
                    }
                }
                ResizeDecorator resizeDecorator =
                    this.Template.FindName("PART_BaseObjectDecorator", this) as ResizeDecorator;
                if (resizeDecorator != null)
                {
                    resizeDecorator.ShowAdorner();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Standard method that is executed when the template 'skin' is applied
        /// (by the WPF framework) on the look-less control.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (this.Template != null)
            {
                // Get links to required child elements inside this control.
                this.mContentPresenter = this.GetTemplateChild("PART_ContentPresenter") as ContentPresenter;
                this.mResizeDecorator  = this.GetTemplateChild("PART_DesignerItemDecorator") as ResizeDecorator;
                ////this.mThumb = this.GetTemplateChild("PART_MoveThumb") as MoveThumb;

                if (this.mResizeDecorator != null)
                {
                    this.mResizeDecorator.AssignDragDeltaEvent(this.ResizeThumb_DragDelta);
                }
            }
        }