Search code examples
c#inlinetextblock

Copy System.Windows.Documents.Inline without modifying it


I'm trying to copy an Inline inline; to a new Inline tempInline inorder to construct a TextBlock textbox = new TextBlock(tempInline); like this tempInline = inline; but the problem is that when I do that my original inline changes/ gets modified.

How can I do that, inline doesnt have a copy or clone method.


Solution

  • I did this,

    string text = XamlWriter.Save(inline);
    Stream s = new MemoryStream(ASCIIEncoding.Default.GetBytes(text));
    Inline temp = XamlReader.Load(s) as Inline;