positioning the connection content

2 posts, 0 answers
  1. al
    al avatar
    15 posts
    Member since:
    Feb 2016

    Posted 21 Aug Link to this post

    hi dear supporters,

    i have used the connection content  and connection points to route the connection.

    now, the connection content is positioned in the middle of the connection but i need to position it in other positions.

    the image is attached.

    my code is also here.

    how can i get the needed position of the connection content.

            private void diagram1_ConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e)
            {
                var image = new System.Windows.Controls.Image() { Source = new BitmapImage(new Uri("components/" + "conn"+ ".png",UriKind.Relative)) };
                System.Windows.Point startPoint= e.Connection.StartPoint;
                System.Windows.Point endPoint= e.Connection.EndPoint;
                double deltaX = Math.Abs(endPoint.X - startPoint.X);
                double deltaY = Math.Abs(endPoint.Y - startPoint.Y);
                image.Stretch=Stretch.Fill;
                image.Width = 0.8*Math.Max(deltaX,deltaY);
                image.Height = 5;
                TextBlock txt = new TextBlock();
                txt.Text = strSelectedComponent;
                StackPanel stpanel = new StackPanel();            
                stpanel.Children.Add(txt);
                stpanel.Children.Add(image);            
                Viewbox viewBox = new Viewbox() { Stretch = Stretch.None, Margin = new Thickness(-4) };
                viewBox.Child = stpanel;
                e.Connection.ConnectionPoints.Add(new System.Windows.Point(endPoint.X,startPoint.Y));
                e.Connection.Content = viewBox;
            }

  2. Dinko
    Admin
    Dinko avatar
    206 posts

    Posted 24 Aug Link to this post

    Hello,

    The behavior explained in your post is not supported by the RadDiagramConnection content out of the box. In order to reposition the content of the connection in the desired position you can implement custom logic which won't be a straightforward task. There is a lot of cases you have to cover in order the content to be on the right/left side of the connection when the routing functionality of the RadDiagram is turn on.

    An approach which I could give you for the case shown in the attached picture is to use the HorizontalContentAlignment (set it to Right) property of the connection and manually calculate the Margin of the ViewBox as is in your case. But still, this approach could work only in this case, as soon as you move any shape the content position won't be correct.

    Regards,
    Dinko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top