Diagram Save/Load Binding Bug :(

2 posts, 1 answers
  1. SPARE GmbH
    SPARE GmbH avatar
    18 posts
    Member since:
    Mar 2012

    Posted 06 Jul 2012 Link to this post


    I've got the following Problem.
    If i Save the Diagram to String and Load the string back into the same Diagram, my binding doesn't work anymore.
    Bug inside the Diagram Framework or OSI Layer 9 (20 cm in the front of the monitor) ?

    <telerik:RadDiagramShape x:Class="SPARE_BPMS_Framework.Shapes.General.ProcessShape"
                 mc:Ignorable="d" Content="{Binding}"
                 d:DesignHeight="300" d:DesignWidth="300">
            <DataTemplate x:Key="editTemplate">
                <StackPanel Orientation="Horizontal">
                    <TextBox Height="24" Text="{Binding Name}" />
            <DataTemplate x:Key="template">
                <WrapPanel Orientation="Vertical">
                    <TextBlock Text="{Binding Name}" />
                    <TextBlock Text="{Binding ChildProcessName}" />

    Code Behinde
    public partial class ProcessShape : RadDiagramShape
            public ProcessItem Model { get; set; }
            public string Name { get; set; }
            public ProcessShape()
                Model = new ProcessItem();
                this.EditTemplate = (DataTemplate)this.FindResource("editTemplate");
                this.ContentTemplate = (DataTemplate)this.FindResource("template");
                this.DataContext = Model;
                this.MouseDoubleClick += new MouseButtonEventHandler(Model.shape_MouseDoubleClick);
            public void Update()
                this.EditTemplate = (DataTemplate)this.FindResource("editTemplate");
                this.ContentTemplate = (DataTemplate)this.FindResource("template");

    Method who call the Reload and Load
    string temp = diagram.Save();



  2. Answer
    Miro Miroslavov
    Miro Miroslavov avatar
    588 posts

    Posted 10 Jul 2012 Link to this post

    Hello Alfred,

     This is already answered in support thread, but I'll summarize the idea so that other guys can benefit of it.
    Every time a diagram is deserialized (loaded), all the shapes are newly created, so all Binding related properties (DataContext, Templates)  should be manually set, since they are not saved by the diagram. (Here is the list of saved properties).
    So here is the example code that should set the appropriate properties.

    (e.Shape as RadDiagramShape).Content = new DataItem();
    (e.Shape as RadDiagramShape).ContentTemplate = this.grid.FindResource("template") as DataTemplate;
    (e.Shape as RadDiagramShape).EditTemplate = this.grid.FindResource("editTemplate") as DataTemplate;

    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
Back to Top