Completed
Last Updated: 19 Aug 2016 09:37 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 18 Aug 2016 05:48
Category: Diagram, DiagramRibbonBar, DiagramToolBox
Type: Bug Report
0
FIX. RadDiagram - StackOverflowException when binding RadDiagram and SelectionMode is set to None
To reproduce:

public Form1()
{
    InitializeComponent();

    this.radDiagram1.SelectionMode = Telerik.Windows.Diagrams.Core.SelectionMode.None;
    PopulateWithData();
}

private void PopulateWithData()
{
    DataTable tasksTable = new DataTable("Tasks");   
    tasksTable.Columns.Add("Id");
    tasksTable.Columns.Add("Text");
    tasksTable.Columns.Add("Type");
    tasksTable.Columns.Add("X");
    tasksTable.Columns.Add("Y");
    tasksTable.Columns.Add("Width");
    tasksTable.Columns.Add("Height");
    tasksTable.Rows.Add("Task1", "Task 1", "circle", 100, 300, 50, 50);
    tasksTable.Rows.Add("Task2", "Task 2", "rectangle", 200, 100, 100, 100);
    tasksTable.Rows.Add("Task3", "Task 3", "circle", 300, 300, 50, 50);
    tasksTable.Rows.Add("Task4", "Task 4", "rectangle", 400, 100, 100, 100);
    tasksTable.Rows.Add("Task5", "Task 5", "circle", 500, 300, 50, 50);

    DataTable relationsTable = new DataTable("Relations");
    relationsTable.Columns.Add("SourceTaskId");
    relationsTable.Columns.Add("SourceConnector");
    relationsTable.Columns.Add("TargetTaskId");
    relationsTable.Columns.Add("TargetConnector");
    relationsTable.Columns.Add("StartCapField");
    relationsTable.Columns.Add("EndCapField");
    relationsTable.Rows.Add("Task2", "Left", "Task1", "Auto", "Arrow5Filled", "Arrow1");
    relationsTable.Rows.Add("Task2", "Auto", "Task3", "Auto", "Arrow4Filled", "Arrow1Filled");
    relationsTable.Rows.Add("Task4", "Auto", "Task5", "Auto", "Arrow2Filled", "Arrow2");

    DataSet ds = new DataSet();
    ds.Tables.Add(tasksTable);
    ds.Tables.Add(relationsTable);

    this.radDiagram1.DataSource = ds;

    this.radDiagram1.ConnectionDataMember = "Relations";
    this.radDiagram1.ShapeDataMember = "Tasks";
    this.radDiagram1.ShapeIdMember = "Id";  
    this.radDiagram1.ShapeTextMember = "Text";
    this.radDiagram1.ShapeTypeMember = "Type";
    this.radDiagram1.ShapeXMember = "X";
    this.radDiagram1.ShapeYMember = "Y";
    this.radDiagram1.ShapeWidthMember = "Width";
    this.radDiagram1.ShapeHeightMember = "Height";

    this.radDiagram1.ConnectionSourceShapeIdMember = "SourceTaskId";
    this.radDiagram1.ConnectionTargetShapeIdMember = "TargetTaskId";
    this.radDiagram1.ConnectionSourceCapTypeMember = "StartCapField";
    this.radDiagram1.ConnectionTargetCapTypeMember = "EndCapField";

    this.radDiagram1.ConnectionSourceConnectorMember = "SourceConnector";
    this.radDiagram1.ConnectionTargetConnectorMember = "TargetConnector";
}

Workaround: after rebinding, clear the selection and set the SelectionMode to None:

PopulateWithData();
this.radDiagram1.SelectedItem = null;
this.radDiagram1.SelectionMode = Telerik.Windows.Diagrams.Core.SelectionMode.None;
0 comments