Page 1 of 1

view.Content.FindName performance impact

Posted: 13 Dec 2023, 12:08
by aliagha.huseynli
Hi Noesis Team,

I use a lot from FindName to get any element in XAML.
If I use over 50 or more of this code will I face any performance issues in my Unity project?
private TextBlock TextBlock1;

void Start
{
NoesisView view = GetComponent<NoesisView> ();
view.Content.DataContext = this;
TextBlock1 = view.Content.FindName (nameof (TextBlock1)) as TextBlock;
}

Re: view.Content.FindName performance impact

Posted: 14 Dec 2023, 10:35
by sfernandez
Calling FindName on the the View.Content will be a pretty fast operation because the lookups are done on a map that is stored in the Content element. So you shouldn't have any performance issues because of this.

Have you found any trouble with it?

Re: view.Content.FindName performance impact

Posted: 14 Dec 2023, 13:12
by jsantos
Just a note for future readers, although FindName is a fast operation, we don't recommend doing it per frame.

Re: view.Content.FindName performance impact

Posted: 15 Dec 2023, 06:22
by aliagha.huseynli
No, I didn't find any problem with it. I just want to make sure about it. Thanks a lot :)