This is a migrated thread and some comments may be shown as answers.

Question about RadDiagramShape Content Serialization

3 Answers 149 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Jiaqi
Top achievements
Rank 1
Jiaqi asked on 03 Aug 2012, 05:23 AM
hello!

I am a beginner of dev and have a question about RadDiagramShape content serialization.
if RadDiagramShape content includes some controls (for example:stackpanel image,textblock) ,how to serializate it?

RadDiagram.Save() and RadDiagram.Load() couldn't   serialize shape content!


Thanks in advanced!

3 Answers, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 03 Aug 2012, 07:04 AM
Hi,

 The diagram will not serialize any UIElement or business object set as content of the diagram item. Moreover, we are only serializing string objects. If you want to serialize the content, you have to do it manually using the ShapeSerialized and ShapeDeserialized events. You can see how to do this in our online help article here.

Kind regards,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kidder
Top achievements
Rank 1
answered on 07 Dec 2012, 09:32 AM
Hi,
I couldnt work this example on your article.

  void diagram_ShapeDeserialized(object sender, Telerik.Windows.Controls.Diagrams.ShapeSerializationRoutedEventArgs e)
        {
            // load the saved property
            (e.Shape as RadDiagramShape).Opacity = Convert.ToDouble(e.SerializationInfo["Opacity"], CultureInfo.InvariantCulture);
        }

        void diagram_ShapeSerialized(object sender, Telerik.Windows.Controls.Diagrams.ShapeSerializationRoutedEventArgs e)
        {
            // save custom or other property
            e.SerializationInfo["Opacity"] = (e.Shape as RadDiagramShape).Opacity.ToInvariant();

        }

It gives below errors:
Error17'double' does not contain a definition for 'ToInvariant' and no extension method 'ToInvariant' accepting a first argument of type 'double' could be found (are you missing a using directive or an assembly reference?)

Please send me an working example..
0
Tina Stancheva
Telerik team
answered on 12 Dec 2012, 10:23 AM
Hello Kidder,

Thank you for bringing this issue to our attention.

The Double.ToInvariant() extension method is defined in the Telerik.Windows.Diagrams.Core namespace and you need to add a using statement for it:
using Telerik.Windows.Diagrams.Core;

I attached a sample solution based on the Serialization article content. And I will update the content of the article to note the using statement as soon as possible.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Diagram
Asked by
Jiaqi
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Kidder
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or