Edit:Here is one solution to store graphics locally but you should store stuff to your database if you can. In my case, we needed to store non-saved graphics temporarely so I came up with this kind of ideaEdit end.Long time ago I wrote serialization extensions for Silverlight and I just ported that to WPF to see if the solution works also in it and with fast test it seems more or less to work. <br><br>The idea was to save deserialized information to string that you can save to file or database. In serialization I use XamlWriter internally.The systems works like this:You define graphics layer you want to store
<esri:GraphicsLayer ID="glayer" x:Name="glayer">
Add execution logic (here 2 buttons with clicks to keep sample clean)
<Button Click="SerializeClick">Serialize</Button>
<Button Click="DeserializeClick">Deserialize</Button>
private string serializedData;
private void SerializeClick(object sender, RoutedEventArgs e)
{
var graphicsLayer = Map.Layers["glayer"] as GraphicsLayer;
// Serialize layer and set result to private variable
this.serializedData = graphicsLayer.SerializeGraphics();
graphicsLayer.ClearGraphics();
}
private void DeserializeClick(object sender, RoutedEventArgs e)
{
var graphicsLayer = Map.Layers["glayer"] as GraphicsLayer;
graphicsLayer.DeserializeGraphics(this.serializedData);
// Reset serialized data
this.serializedData = string.Empty;
}
Here you have serializedData string that contains the serialized data. Now you can do what you want with it.NOTE: I haven't tested this solution in WPF more then this example!The solution should be reviewed in code level to make it more WPF and newest ArcGIS API opitimized. When I wrote that we didnt have stuff like ToJson() and Silverlight does not support XamlWriter out of the box so thing might work differently in WPF than in Silverlight.What we did in Silverlight, we created quite large graphic writing capabilities with opacity controls, border and fill customizations etc. and that worked quite well even thou in larger objects the serialized string is huge but that did the work.Here are sample app how I tested the porting. Also if someone is brave (or grazy) enough to my solution in their code, let me know (private message) and I will test / clean this solution and give the assembly or even code to do it if you really need it.