Try as I might, I cannot reproduce your problem. I think there is more at play than the code you have posted. This works fine for me.
Up vote 3 down vote favorite share g+ share fb share tw.
I am trying to alias a resource in XAML, as follows: oldName simply refers to a resource of type Image, defined in App.xaml. As far as I understand, this is the correct way to do this, and should work fine. However, the XAML code gives me the superbly unhelpful error: "The application XAML file failed to load.
Fix errors in the application XAML before opening other XAML files. " This appears when I hover over the StaticResourceExtension line in the code (which has a squiggly underline). Several other errors are generated in the actual Error List, but seem to be fairly irrelevant and nonsenical (such messages as "The name 'InitializeComponent' does not exist in the current context"), as they all disappear when the line is removed.
I'm completely stumped here. Why is WPF complaining about this code? Any ideas as to a resolution please?
Note: I'm using WPF in . NET 3.5 SP1. Update 1: I should clairfy that I do receive compiler errors (the aforementioned messages in the Error List), so it's not just a designer problem.
Update 2: Here's the relevant code in full... In App. Xaml (under Application. Resource): And in MyUserControl.
Xaml (under UserControl. Resources): These are the lines that generate the errors, of course. Wpf xaml resources aliasing link|improve this question edited Jul 22 '09 at 8:30 asked Jul 17 '09 at 14:29Noldorin41.6k973157 86% accept rate.
Try as I might, I cannot reproduce your problem. I think there is more at play than the code you have posted. This works fine for me: App.
Xaml: Window1. Xaml: UserControl1. Xaml: I added the Leaves.
Jpg image to my project and it displayed just fine.
Thanks for the reply. And no, unfortunately actual compiler errors are generated (nonsense messages that all go away if I don't define the aliases). Not sure if it makes a difference, but did you notice that the resources I'm using are Image elements?
– Noldorin Jul 20 '09 at 22:36 Can you post your full code? – Kent Boogaart Jul 21 '09 at 8:29 @Kent: Updated my original question. Thanks for staying with this... – Noldorin Jul 22 '09 at 8:31 I've updated my answer - it's still working fine for me.
I've even gotten an image to display inside the UserControl. – Kent Boogaart Jul 22 '09 at 9:49 @Kent: I repdroduced your example and it seems to be working fine for me too. (Should have tried that earlier, to be honest!
) To be precise here, I am actually nesting the resources in App. Xaml in a ResourceDictionary, but this doesn't make a difference in my example project. This issue has really stumped me... Does the 'InitializeComponent' error give you any hints perhaps?
– Noldorin Jul 22 '09 at 10:40.
I tried using the same setup as Kent and received the following error: Property 'Resources' does not support values of type 'System.Windows.Controls. Image'. I also tried a few other types and got the same thing (only with a different full-qualified type name).
I was only able to re-key an Image in the in the following way: I have to wonder: Why? Resources weren't designed to be re-keyed. I have a suspicion that what you are ultimately trying to accomplish could be done better and easier in some other way.
Possibly with setters in a style.
1 I received the same error, but I noticed that the project actually built successfully. I was able to run the project and it worked as desired. I think your particular error may be coming from a XAML validator inside of VS that has no bearing on the build process.
– Bryce Kahle Jul 30 '09 at 2:24 You're right. So it wasn't my eyes playing tricks on when I thought it said 'Build succeeded' a split second before the error panel popped up. – Joel B Fant Jul 30 '09 at 13:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.