[英]Cannot create unknown type error
例外:無法創建未知的類型錯誤“'{http://schemas.telerik.com/2008/xaml/presentation}RadDatePicker'”
public static object Visualize(string filepath)
{
try
{
var xdoc = new XDocument(XElement.Parse(new StreamReader(filepath).ReadToEnd()));
Code = xdoc.ToString();
XmlReader xmlReader = xdoc.CreateReader();
return XamlReader.Load(xmlReader); //<-- thrown here
}
catch(Exception e)
{
System.Windows.MessageBox.Show(e.Message,"Visualize error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
return null;
}
}
當我使用包含該組件的xaml文件調用上述方法時,在運行時發生異常。 如果我調用同一文件,但是缺少聲明組件的部分,則可以正常工作。
我如何解決它?
該問題可能來自您自己的XAML代碼,該代碼需要XAML上不存在的資源。 如果您在App.xaml上具有合並的資源,請不要期望XAML控件會看到該資源。 我遇到了同樣的問題,必須在控件XAML視圖上再次明確定義合並的資源。
我的問題在下面,有點誤導了實際原因。
Cannot create unknown type '{http://schemas.telerik.com/2008/xaml/presentation}RadGridView'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.