Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 631149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:56:00+00:00 2026-05-13T19:56:00+00:00

I am playing around with some stuff in Silverlight, and I am trying to

  • 0

I am playing around with some stuff in Silverlight, and I am trying to dynamically draw a curved line between two other objects on a <Canvas/>. I tried doing something like this:

public partial class MainNodeConnection : UserControl
{
private MainNode _sourceNode;
public MainNode SourceNode
{
get { return _sourceNode; }
set { _sourceNode = value; }
}

private ChildNode _targetNode;
public ChildNode TargetNode 
{
    get { return _targetNode; }
    set { _targetNode = value; }
}

private double _sourceX;
private double _sourceY;
private double _targetX;
private double _targetY;

private Path _connection;

public MainNodeConnection()
{
    InitializeComponent();
    _connection = new Path();
    this.Content = _connection;
}

public void UpdateLocations()
{
    _sourceX = Canvas.GetLeft(_sourceNode) + (SourceNode.Width/2);
    _sourceY = Canvas.GetTop(_sourceNode) + (SourceNode.Height/2);
    _targetX = Canvas.GetLeft(_targetNode);
    _targetY = Canvas.GetTop(_targetNode);
    string pathData = String.Format("M {0},{1} C {2},{3} {4},{5}", _sourceX, _sourceY, _targetX - _sourceX, _targetY - _sourceX, _targetX, _targetY);
    PathGeometry geoData = new PathGeometry();
    PathFigure pFigure = new PathFigure();
    pFigure.StartPoint = new Point(_sourceX, _sourceY);
    BezierSegment pseg = new BezierSegment();
    pseg.Point1 = new Point(_targetX - _sourceX, _targetY - _sourceY);
    pFigure.Segments.Add(pseg);
    geoData.Figures.Add(pFigure);
    _connection.Stroke = new SolidColorBrush(Colors.Black);
    _connection.StrokeThickness = 1;
    _connection.Data = geoData;
    this.Content = _connection;
}

}

and I built the objects on the <Canvas/> like this:

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
        Loaded += new RoutedEventHandler(MainPage_Loaded);
    }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        MainNodeConnection mnc = new MainNodeConnection();
        mnc.Width = 300;
        mnc.Height = 300;
        Canvas.SetLeft(mnc, Canvas.GetLeft(mainNode1));
        Canvas.SetTop(mnc, Canvas.GetTop(mainNode1));
        mnc.SourceNode = mainNode1;
        mnc.TargetNode = childNode1;
        nodeCanvas.Children.Add(mnc);
        mnc.UpdateLocations();
    }
}

the problem I have is I can’t get the line to show up. Can anyone spot what I’m doing wrong, or is there a different/better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:56:01+00:00Added an answer on May 13, 2026 at 7:56 pm

    You’re missing Point2 and Point3 in the Bezier curve.
    From the help file:

    A cubic Bezier curve is defined by
    four points: a start point, an end
    point (Point3), and two control points
    (Point1 and Point2). The BezierSegment
    class does not contain a property for
    the starting point of the curve; it
    only defines the end point. The
    beginning point of the curve is the
    current point of the PathFigure to
    which the BezierSegment is added.

    The two control points of a cubic
    Bezier curve behave like magnets,
    attracting portions of what would
    otherwise be a straight line toward
    themselves and producing a curve. The
    first control point, Point1, affects
    the beginning portion of the curve;
    the second control point, Point2,
    affects the ending portion of the
    curve. Note that the curve doesn’t
    necessarily pass through either of the
    control points; each control point
    moves its portion of the line toward
    itself, but not through itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm playing around with some swing guis and am trying to create a basic
I am playing around with some recursion, and trying to count the number of
I am trying to set up an Android emulator to do some playing around
I'm playing around with Rhino Mocks and am trying to set some dummy results
I am playing around some windows 8 stuff and wonder how I can do
I'm playing around with some APIs and I'm trying to figure this out. I
I'm playing around with some unit tests and mocking. I'm trying to verify that
I'm playing around with some JPA stuff, changing the mappings to see how they're
I'm just playing around with JSP. I just wanted to test some <jsp:useBean> stuff,
I am playing around with getting some basic stuff to work in Python before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.