3
嘗試在代碼中加載generic.xaml,但會引發XamlParseException。代碼如下:加載generic.xaml合併資源字典時,XamlReader會引發
Uri uri = new Uri("Themes/Generic.xaml", UriKind.Relative);
StreamResourceInfo info = Application.GetResourceStream(uri);
System.Windows.Markup.XamlReader reader = new System.Windows.Markup.XamlReader();
ResourceDictionary resdict = (ResourceDictionary)reader.LoadAsync(info.Stream);
this.Resources.MergedDictionaries.Add(resdict);
這個想法是在basepage中合併一個資源字典。然後派生的頁面可以使用例如{StaticResource DarkBrush}
從他們的基類中的樣式,顏色,畫筆等。
但上面的代碼拋出:
'',十六進制值0x0C,是無效的字符。第1行,位置1.
generic.xaml文件是在VS2010中創建的標準方式。試圖將生成行動設置爲資源,但這也不起作用...
我收到了來自Microsoft的code sample。它曾用於加載頁面。任何幫助將不勝感激。
Thanx!簡單易用的解決方案! –
這裏有什麼問題,它爲什麼顯示錯誤? –
顯示什麼錯誤? –