Adding Tooltip to Dynamically created Shape/Path in Silverlight

As per my client requirement I have to create dymanic shapes like Path in the Silverlight to show the different discount label  for the different sales data labels

I can create theis dynamic paths in two ways.
1.By creating dynamic Xaml and  using the Xaml.Reader in the code behind .

StringBuilder pathData = new StringBuilder();
            //move to circle center
            pathData.Append("M ");
            Point circleCenter = new Point();
            circleCenter.X = 200;
            circleCenter.Y = 200;
            pathData.Append(circleCenter.ToString());
     //draw line to edge of circle, to the first calculated endpoint
            pathData.Append(" L ");
            Point circumPoint = new Point();
            circumPoint.X = 290;
            circumPoint.Y = 200;
           pathData.Append(circumPoint.ToString());
    //(or the first calculated point if it is the last drawn segment)
           pathData.Append(" C ");
          // pathData.Append(circleCenter.ToString());
           pathData.Append("300,180 290,170 285,165 L ");
           pathData.Append(circleCenter.ToString());
            //int check = i + 1;
            //if (check == _sectionCount)
            //    check = 0;
           // pathData.Append(circlePoints[check].ToString());
      //close the section shape (renders line back to the center point)
           //pathData.Append(" Z ");

    //Cannot add string path directly to Data property, so it must be injected, also inserts tool tip xaml
            string sectionTip = "";
            string nsPath = "" + sectionTip + "");
            section.Stroke = new SolidColorBrush(Colors.Black);
            section.StrokeThickness = 2;
            
            //color the newly created section
            section.Fill = new SolidColorBrush(Colors.Red);
         //   section.SetValue(ToolTipService.ToolTipProperty, "22 %");
            //if (colorIndex + 1 == _colors.Length)
            //    colorIndex = 0;
            //else
            //    colorIndex++;

            //add filled path
            this.LayoutRoot.Children.Add(section);

            This this way I can esily add the tool tip but as my requirement is not satisfied because the of the below problem So I have to discard this way.
            
            But what happen in this case if the  the  if the angle in the center for the two points is more then 90 degree then the path is not created as circular so This did not achive my requrement .
            
            So I have achieved my requirement this  below way.
            
            
            // Segment Geometry
            PathSegmentCollection segments = new PathSegmentCollection();

            // First line segment from pt p1 - pt p2
            segments.Add(new LineSegment() { Point = p2 });

            //Arc drawn from pt p2 - pt p3 with the RangeIndicatorRadius 
            segments.Add(new ArcSegment()
            {
                Size = new Size(arcradius2, arcradius2),
                Point = p3,
                SweepDirection = SweepDirection.Clockwise,
                IsLargeArc = reflexangle

            });

            // Second line segment from pt p3 - pt p4
            segments.Add(new LineSegment() { Point = p4 });

            //Arc drawn from pt p4 - pt p1 with the Radius of arcradius1 
            segments.Add(new ArcSegment()
            {
                Size = new Size(arcradius1, arcradius1),
                Point = p1,
                SweepDirection = SweepDirection.Counterclockwise,
                IsLargeArc = reflexangle

            });

            // Defining the segment path properties
            Color rangestrokecolor;
            if (clr == Colors.Transparent)
            {
                rangestrokecolor = clr;
            }
            else
                rangestrokecolor = Colors.White;

 

            rangeIndicator = new Path()
            {
                StrokeLineJoin = PenLineJoin.Round,
                Stroke = new SolidColorBrush(rangestrokecolor),
                //Color.FromArgb(0xFF, 0xF5, 0x9A, 0x86)
             // Fill = new SolidColorBrush(clr),
                Opacity = 0.65,
                StrokeThickness = 0.25,
                Data = new PathGeometry()
                {
                    Figures = new PathFigureCollection()
                     {
                        new PathFigure()
                        {
                            IsClosed = true,
                            StartPoint = p1,
                            Segments = segments
                        }
                    }
                }
            };

After that My next challenge was to add the ToolTip to the dynamically created Path. After googling for some time I did not find any solution for it .

After that i think that in the SetValue() we can set any dependency Property and ToolTipService.ToolTIp is a Attached Property And also a dependency Property .For detail knowledge about  How  ToolTIpService.ToolTip is a dependency Property .Click here So what I do is


rangeIndicator.SetValue(ToolTipService.ToolTipProperty, “Tooltip is here”);

It was my goal and It Works fine provided you have to Fill() the path.

150 150 Burnignorance | Where Minds Meet And Sparks Fly!