I have an UltraTilePanel that allows the user to drag around a 3x3 grid of tiles in any order. I would like to persist this tile order in a settings file. I'm using SaveAsXml/LoadFromXml on the panel control and saving the XML string to a property in an enclosing XML settings file. The deserialization seems to be working correctly (no exceptions), but the tile order is not persisted correctly. Some tiles will be in the correct position as before, but others are out of place. Is this a known bug with the panel?
Here is my serialzation code:
//Write the field tile order out to settings using (var memStream = new MemoryStream()) { ultraTilePanel1.SaveAsXml(memStream); memStream.Position = 0; using (var sr = new StreamReader(memStream)) { pluginSettings.Add("FieldTileOrder", sr.ReadToEnd()); } }
And here is my deserialization code:
var tileLayout = pluginSettings["FieldTileOrder"]; using (var memStream = new MemoryStream()) { using (StreamWriter sw = new StreamWriter(memStream)) { sw.Write(tileLayout); sw.Flush(); memStream.Position = 0; ultraTilePanel1.LoadFromXml(memStream); } }
Hi Daniel,
I believe the expected result is that the tiles will retain their order. Does the issue occur if you use SaveAsXml without appending anything to the file? I'm guessing that pluginSettings.Add doesn't do anything to interfere with UltraTilePanel's saved layout, but I can't know for sure without seeing it. Are you able to provide a sample that I can run to test this? Please let me know.
Thank you for the response. Using SaveAsXml/LoadFromXml directly to a file gives me the same behavior, unfortunately. The tiles do not seem to be restored in any logical order.
However, I created a small sample app with the same number of tiles and layout, and the save/load restores the layout correctly. There must be something specific to my tile panel or the enclosing control that is causing this issue. I'll investigate further and see if I can figure out something else to ask.
Thanks for doing that test. If you are able to provide your application, I can look into it as well to see if I can identify the issue.