Facing problem in Silverlight Path Control
Last post 07-18-2007 9:43 AM by luisabreu. 2 replies.
Sort Posts:
07-18-2007 6:19 AM
Facing problem in Silverlight Path Control

I am working on a project using Microsoft silverlight. I am facing some problems and looking for your positive reply. I need some a conainer controls (for Path control) which can hold other controls in them. According to my requirments I have to design geometric shape. and then have to add some other shapes(using path control) to it. But I am facing problems as path control is not a container. One other thng is that when I draw some shape. I converts it to path and Data attribute of shows (Data="M87,143 L113,149 143,151 173,152 207,151 227,147 234,146 224,226 203,229 177,231 143,231 114,228 94,225 z") these type of values. I have to change the shape at runtime. Data attribute returns of path reutrns "PathGeometry" object. I diagnosed all areas of PathGeometry but unable to get those values. Please tell me that how can I get and change those values in runtime. Please reply me becouse this problem is delaying my project time line.

Regards

Adnan Amin
MCPD,MCTS for Web and Windows based client applications
Software Engineer
Kalsoft (Pvt) Ltd
http://adnanamin.blogspot.com/

Adnan.Amin

Loading...
Joined on 07-11-2007
Pakistan
Posts 53
07-18-2007 9:15 AM
Re: Facing problem in Silverlight Path Control

I faced a similar problem, and could never retrieve the PathFiguers defined in the Data attribute. I could manipulate it only if I defined the PathGeomtry in my code, here is an example

Path p = new Path();
            p.SetValue(Path.NameProperty, "myPath");
            PathGeometry g = new PathGeometry();
            PathFigure f = new PathFigure();
            f.StartPoint = new Point(10, 10);
            LineSegment seg = new LineSegment();
            seg.Point = new Point(10, 100);
            LineSegment seg2 = new LineSegment();
            seg2.Point = new Point(100, 100);
            LineSegment seg3 = new LineSegment();
            seg3.Point = new Point(100, 10);
            f.Segments = new PathSegmentCollection();
            f.Segments.Add(seg);
            f.Segments.Add(seg2);
            f.Segments.Add(seg3);
            g.Figures = new PathFigureCollection();
            g.Figures.Add(f);
            p.Data = g;
            p.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            p.SetValue(Canvas.TopProperty, 10);
            p.SetValue(Canvas.LeftProperty, 10);
            this.Children.Add(p);

Then later based on a click event I retrieved the Path data

    public void onCLick(object sender, EventArgs e)
        {
            Path p = (Path)this.FindName("myPath");
            PathGeometry g = (PathGeometry)p.Data;
            foreach (PathFigure f in g.Figures)
            {
                foreach (PathSegment seg in f.Segments)
                {
                    seg.ToString();
                }
            }
        }

 Hopefully this issue is fixed in the next release, because it is really painful to define path data in code.

Thanks
Yasser Makram
My Blog: http://www.silverlightrecipes.com
Sr. Architect
Santeon Inc. Microsoft Silverlight Partner, Solution Provider

y_makram

Loading...
Joined on 06-07-2007
Cairo, Egypt
Posts 1,141
07-18-2007 9:43 AM
Re: Facing problem in Silverlight Path Control

Hello again.

Yasser is right. i've seen it happen too! it looks like shapes and geometries have some bugs when you try to access their collections and they're instantiated from xaml by the silverlight parser.

luisabreu

Loading...
Joined on 04-30-2007
Posts 612
Page view counter