Unplanned
Last Updated: 04 Mar 2019 11:39 by ADMIN
ADMIN
Milena
Created on: 03 Jul 2015 13:00
Category: Diagram
Type: Feature Request
6
Diagram: Change the ConnectionPoints property of the RadDiagramConnection to be DependencyProperty
A possible workaround is to use an attached property. Basically, we've added ConnectionPointsProperty in AttachedProperties class and added binding to this new property in the style of the connection.

public class AttachedProperties
    {
        public static RadDiagram Diagram { get; set; }

        public static readonly DependencyProperty ConnectionPointsProperty =
           DependencyProperty.RegisterAttached("ConnectionPoints", typeof(List<Point>), typeof(AttachedProperties), new PropertyMetadata(null, OnConnectionPointsChanged));

        public static IEnumerable<Point> GetConnectionPoints(DependencyObject obj)
        {
            return (IEnumerable<Point>)obj.GetValue(ConnectionPointsProperty);
        }

        public static void SetConnectionPoints(DependencyObject obj, IEnumerable<Point> value)
        {
            obj.SetValue(ConnectionPointsProperty, value);
        }

        private static void OnConnectionPointsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var connection = d as RadDiagramConnection;
            var connectionPoints = e.NewValue as List<Point>;
            if (connection != null && connectionPoints != null)
            {
                for (int i = 0; i <  connectionPoints.ToList().Count; i++)
                {
                    connection.ConnectionPoints.Add(connectionPoints.ToList()[i]);                 
                }
                connection.IsModified = true;
                (connection as IConnection).Update();
            }
        }
    }



  <telerik:RadDiagram.ConnectionStyle>
                <Style TargetType="telerik:RadDiagramConnection">
                    <Setter Property="ConnectionType" Value="Polyline"/>
                    <Setter Property="local:AttachedProperties.ConnectionPoints" Value="{Binding MyConnectionPoints}"/>
                </Style>
            </telerik:RadDiagram.ConnectionStyle>
1 comment
Imported User
Posted on: 06 Jul 2015 06:22
This would help the design of the diagram because the ConnectionPoints will be able to be added in XAML and therefore be rendered in the designer.