I. Overview of the Presentation
This demo shows how to save layout information through the Savelayout () provided by the Raddocking control itself, and to load layout information through the Loadlayout () method. As a result, you can persist user-defined layout information to a file, and when the user opens the app again, you can restore the layout intact.
Related downloads (screen recording): http://pan.baidu.com/s/1gd6DwDt
Play Online: http://v.youku.com/v_show/id_XODcyNjE0Mjg4.html
Warm Tips: If the screen recording and code can not be downloaded properly, you can leave a message in the station, or send an email to [email protected]
second, the operation effect
The effect is as follows:
Three, the key code
1, save the layout of the Code
<summary>///converts the layout information of the raddocking to a string. </summary>///<returns></returns>private String savelayoutasstring () {MemoryStream stream = new MemoryStream (); Raddocking.savelayout (stream); stream. Seek (0, Seekorigin.begin); StreamReader reader = new StreamReader (stream), return reader. ReadToEnd ();}
2. Loading the layout code
<summary>///loads the raddocking layout information from the string. </summary>///<param name= "xml" ></param>private void Loadlayoutfromstring (string xml) {using ( Stream stream = new MemoryStream (Encoding.UTF8.GetBytes (XML))) {stream. Seek (0, Seekorigin.begin); Raddocking.loadlayout (stream);}}
3. Persisting the generated XML
The raddocking layout persists the resulting string, which is also an XML, which is roughly as follows:
<?xml version= "1.0" encoding= "Utf-8"?><raddocking> <DocumentHost> <RadSplitContainer> < ;items> <radpanegroup selectedindex= "0" > <Items> <radpane serializationtag= "L Ayoutxml "isdockable=" True "header=" Layout Xml "/> <raddocumentpa Ne serializationtag= "documentpane" isdockable= "True" title= "Docume NT 1 "header=" Document 1 "/> </Items> </RadPaneGroup> < /items> </RadSplitContainer> </DocumentHost> <SplitContainers> <radsplitcontainer dock= "do Ckedleft "Width=" > <Items> <radpanegroup selectedindex= "0" > <Items> <radpane serializationtag= "PaneLeft1" isdockable= "True" Header= "Pane left 1"/> <radpane serializationtag= "PaneLeft2" isdockable= "True" header= "Pane left 2"/> <radpane serializationtag= "PaneLeft3" isdockable= "True" Header= "Pane left 3"/> <radpane serializationtag= "PaneLeft4" isdockable= "Tru E "header=" Pane Left 4 "/> </Items> </RadPaneGroup> </Items> </RadSplitContainer> <radsplitcontainer dock= "Dockedright" width= "Up" > < items> <radpanegroup selectedindex= "0" > <Items> <radpane serializationtag= "Pa NeRight1 "isdockable=" True "header=" Pane right 1 "/> </Items> </RadPaneGroup> </Items> </RadSplitContainer> <radsplitcontainer dock= "Dockedtop" Height= "> <Items> <radpanegroup selectedindex=" 0 "> <Items> <radpane Serializationtag= "PaneTop1" isdockable= "True" header= "Pane Top 1"/> </Items> </RadPaneGroup> </Items> </RadSplitContainer> </splitcontainers>< ;/raddocking>
Iv. Related Resources
1, Telerik official Help document address: Http://docs.telerik.com/devtools/wpf/controls/raddocking/overview2
[Telerik] Raddocking No. 02 Save and load the layout of raddocking