Page 1 of 1

How to load xaml from StreamingAssets?

Posted: 11 Oct 2021, 09:06
by sericaer
I want load xaml from StreamingAssets, so I try below code, which changed from Samples\Gallery\MainWindow.xaml.cs
            //string sampleName = string.Format("Assets/NoesisGUI/Samples/Gallery/Samples/{0}.xaml", _selectedSample.Name);
            //FrameworkElement sample = (FrameworkElement)Application.LoadComponent(new Uri(sampleName, UriKind.Relative));

            string sampleName = UnityEngine.Application.streamingAssetsPath + "/Button.xaml";
            FrameworkElement sample = (FrameworkElement)Application.LoadComponent(new Uri(sampleName, UriKind.Absolute));
But the Unity report error:
[NOESIS/E] Xaml not found 'D:/temp/Tutorials-master/Samples/Gallery/Unity/Assets/StreamingAssets/Button.xaml'

How to load xaml from StreamingAssets?

Best regards!

Re: How to load xaml from StreamingAssets?

Posted: 13 Oct 2021, 11:43
by jsantos
I am sorry to say this is not supported. You have the following alternatives:
Noesis.GUI.LoadXaml(Stream stream, string filename)
Noesis.GUI.ParseXaml(string xamlText)
But they don't work if you have dependencies (fonts, images, dictionaries, etc).