WPF - clone a databound object?
I am trying to clone a WPF bound object (a listbox) with code like the following
pgeIncidentReport newPage = new pgeIncidentReport();
newPage.SetReportData();
string listXaml = XamlWriter.Save(newPage.lstUsers);
However, when you view the listXaml string, I noticed that my databinding directives, for both the list itself and the DataTemplate are blank and n开发者_StackOverflowo longer there. Is there a reason why that is being removed? Is there another way to clone objects that will maintain all of the settings?
Hate to answer my own question, but I found the answer by using this class: http://www.codeproject.com/KB/WPF/XamlSerializer.aspx
This article also helped to a certain degree but the solution in the first article is much easier to implement: http://www.codeproject.com/KB/WPF/xamlwriterandbinding.aspx?fid=1428301&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2801571
精彩评论