Paragraph p = new Paragraph();
void Function(var inline)
{
var r = (inline);
string rSer = XamlWriter.Save(r);
var inl1 = XamlReader.Parse(rSer);
p.Inlines.Add(inl1); // error The best overloaded method match for System.Windows.Documents.InlineCollection.Add(System.Windows.UIElement)' has some invalid arguments
}
inline type can be System.Windows.Documents.Run or System.Windows.Documents.Span.
How do I know the type of inline and lead to it?
I need something like this:
Type t = Type.GetType(inline.GetType().ToString()); // results in t == null
p.Inlines.Add(inline as t);