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