- solaris783
- Posts: 5
- Joined:
How to track down Xaml path errors?
I have this line in my xaml:
I get the error:
The xaml calling NocturnalStyle works in VS Blend and in Kaxaml -- those design tool load the resource just fine. The file "NocturnalStyle" is in the same folder as the main xaml calling it. I also tried to put it in other places like where the VS project is or executable as well as putting an absolute path there, but Noesis never finds it. I re-wrote the line to be more explicit as well:
which also works in VS Blend, but not in Noesis (still can't find it).
The "Xaml provider not set" was fixed with the addition of:
but it still can't find NocturnalTheme.xaml.
I also tried:
which yielded the same results.
How do I fix this?
Code: Select all
<ResourceDictionary Source="NocturnalStyle.xaml"/>
Code: Select all
[NOESIS/I] 'NoesisTheme.xaml' loaded
[NOESIS/E] Xaml provider not set
[NOESIS/E] <memory>(13): Xaml not found 'NocturnalStyle.xaml'
Code: Select all
<ResourceDictionary Source="/IntegrationGLUT-blend;component/NocturnalStyle.xaml"/>
The "Xaml provider not set" was fixed with the addition of:
Code: Select all
GUI::SetXamlProvider(MakePtr<NoesisApp::LocalXamlProvider>(""));
I also tried:
Code: Select all
GUI::SetXamlProvider(MakePtr<NoesisApp::LocalXamlProvider>(""));
Noesis::Ptr<Noesis::Grid> main = Noesis::GUI::LoadXaml<Noesis::Grid>("../IntegrationGLUT-blend/UserControl1.xaml");
How do I fix this?
- solaris783
- Posts: 5
- Joined:
Re: How to track down Xaml path errors?
I'm not sure if I'm doing this right but I solved it by pre-loading the resources the xamls reference. a) I thought that because the error said, "xaml not found" that it couldn't find the file. It seems like it doesn't look for a file, it looks for a resource in memory that's supposed to be already loaded. b) I thought that if a xaml file referenced another xaml file, that LoadXaml would (should) load the second one automatically from disk. c) literally no examples of this workflow found in the examples or online documentation.
Here's the code:
and the xaml just needs this for referencing my Style file:
Here's the code:
Code: Select all
GUI::SetFontProvider(MakePtr<NoesisApp::LocalFontProvider>(""));
GUI::SetTextureProvider(MakePtr<NoesisApp::LocalTextureProvider>(""));
GUI::SetXamlProvider(MakePtr<NoesisApp::LocalXamlProvider>(""));
// the following path is relative to where the .vcxproj is:
Noesis::Ptr<Noesis::ResourceDictionary> noct = Noesis::GUI::LoadXaml<Noesis::ResourceDictionary>("../IntegrationGLUT-blend/NocturnalStyle.xaml");
Noesis::Ptr<Noesis::Grid> main = Noesis::GUI::LoadXaml<Noesis::Grid>("../IntegrationGLUT-blend/UserControl1.xaml");
Code: Select all
<ResourceDictionary Source="NocturnalStyle.xaml"/>
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: How to track down Xaml path errors?
Noesis needs a XamlProvider to load xaml resources as you found.
The LocalXamlProvider looks for files in disk by appending the specified path root to the current directory, so usually you have to place your xaml files next to the .exe file in order to find them.
For example, if you have:
And set the LocalXamlProvider as:
To load the MainWindow if the current directory is where application .exe is found, you should write:
And if MainWindow.xaml references inside the xaml the NocturnalStyle.xaml, it can use a relative path:
The xaml parser by using the Uri converter will automatically convert the relative path "NocturnalStyle.xaml" to "Data/NocturnalStyle.xaml" and pass that to the LocalXamlProvider.
There is no need to have resources pre-loaded in memory, just place them in the appropriate directories according to providers configuration.
The LocalXamlProvider looks for files in disk by appending the specified path root to the current directory, so usually you have to place your xaml files next to the .exe file in order to find them.
For example, if you have:
Code: Select all
- XamlTest.exe
+ Data/
--- MainWindow.xaml
--- NocturnalStyle.xaml
Code: Select all
GUI::SetXamlProvider(MakePtr<NoesisApp::LocalXamlProvider>(""));
Code: Select all
Noesis::Ptr<Noesis::Grid> main = Noesis::GUI::LoadXaml<Noesis::Grid>("Data/MainWindow.xaml");
Code: Select all
<Grid x:Class="XamlTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Resources>
<ResourceDictionary Source="NocturnalStyle.xaml"/>
</Grid.Resources>
...
</Grid>
There is no need to have resources pre-loaded in memory, just place them in the appropriate directories according to providers configuration.
Who is online
Users browsing this forum: No registered users and 9 guests