C4ustic
Topic Author
Posts: 8
Joined: 03 Sep 2017, 03:02

Noesis.GUI.LoadComponent(this, "") Why does this work?

20 Oct 2019, 17:12

So everything is working fine but I have noticed that the LoadComponents() function works no matter what string I send in. Noesis.GUI.LoadComponent(this, "asdfasdfasdf"); This is going to run just fine.

It is a little messy to keep the full paths to the .xaml files up if you move files around so to just use Noesis.GUI.LoadComponent(this, "") would be preferable, I just want to know in what case that might come back and bite me.
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Noesis.GUI.LoadComponent(this, "") Why does this work?

21 Oct 2019, 09:47

First of all, passing a wrong path to LoadComponent should log an error because the provided file cannot be found by the XamlProvider.

Apart from that, there are two scenarios when loading a xaml file:
  • When you manually load a xaml using LoadXaml, in this case you are specifying the correct path to the file, so even if your user control had a wrong path in the LoadComponent, it will be able to load it correctly.
  • When you reference another user control in your xaml, in this case you just specify the class name, so the only way to load the associated xaml is by using the LoadComponent specified in the code-behind of the control. If that path is wrong it won't be able to load the control correctly.
So you can't leave the path as "" because your application won't work as expected.
 
C4ustic
Topic Author
Posts: 8
Joined: 03 Sep 2017, 03:02

Re: Noesis.GUI.LoadComponent(this, "") Why does this work?

27 Oct 2019, 20:26

Thanks

Who is online

Users browsing this forum: No registered users and 0 guests