Example #1
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal
        /// processes call <see cref="FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            // Clean up.
            _sectorPath = null;
            _sectorGeometry = null;
            _leaderLinePath = null;
            _leaderLineGeometry = null;
            _innerLabel = null;
            _outerLabel = null;

            // Apply template.
            base.OnApplyTemplate();

            // Get template parts and prepare path geometries.
            _sectorPath = GetTemplateChild("PART_Sector") as Path ?? new Path();
            _leaderLinePath = GetTemplateChild("PART_LeaderLine") as Path ?? new Path();
            _innerLabel = GetTemplateChild("PART_InnerLabel") as ContentControl ?? new ContentControl();
            _outerLabel = GetTemplateChild("PART_OuterLabel") as ContentControl ?? new ContentControl();

            _sectorGeometry = _sectorPath.SetPathGeometry();
            _leaderLineGeometry = _leaderLinePath.SetPathGeometry();
            Invalidate();
        }