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
}
内联类型可以是System.Windows.Documents.Run或System.Windows.Documents.Span。我如何知道对象的类型并导致它?
我如何知道内联的类型并导致它?
我需要的是这样的:
Type t = Type.GetType(inline.GetType().ToString()); // results in t == null
p.Inlines.Add(inline as t);
'void Function(var inline)'不会编译,这会使您的问题变得模糊。 – 2010-09-25 09:12:25
不好的问题,并给予负面的人试图帮助... – Aliostad 2010-09-25 09:48:30
我会避免使用“内嵌作为吨”作为函数的参数,因为它可以返回null – Val 2010-09-25 12:05:59