Topic Author
Posts: 10
Joined: 09 Oct 2021, 09:29

How to load xaml from StreamingAssets?

11 Oct 2021, 09:06

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!
User avatar
Site Admin
Posts: 3547
Joined: 20 Jan 2012, 17:18

Re: How to load xaml from StreamingAssets?

13 Oct 2021, 11:43

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).

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 4 guests