Today I was working with a WPF project and when I went to run the application
I got the following error 'Cannot locate resource 'FileName.xaml'. Note, this
is NOT a compiler error, this is a runtime error.
When I opened up the App.xaml file, the StartupUri appeared to be correct, but I would still get this error. After playing around for a few minutes it dawned on me what the issue is.
Let me explain:
Turns out that in order for the StartupUri to find the xaml form, you need to provide the file path of the file, not name the namespace path of the file. When I did that it all worked.
Hope this helps
When I opened up the App.xaml file, the StartupUri appeared to be correct, but I would still get this error. After playing around for a few minutes it dawned on me what the issue is.
Let me explain:
In my project I created a subfolder to put my views
(forms) into. I named this folder 'Views'. Example:
-> Root
-> Views
-> FileName.xaml
-> Root
-> Views
-> FileName.xaml
Turns out that in order for the StartupUri to find the xaml form, you need to provide the file path of the file, not name the namespace path of the file. When I did that it all worked.
None Working
StartupUri
StartupUri="FileName.xaml"
StartupUri="FileName.xaml"
Working
StartupUriStartupUri="Views/LayoutEditor.xaml"
Hope this helps
No comments:
Post a Comment