How can I identify the element I am looking for prior to it being loaded using WebDriverWait

I’m writing a test for a WPF desktop application using Appium. I need to wait for an element to appear. I have the following code:

WebDriverWait testWait = new WebDriverWait(driver, TimeSpan.FromSeconds(7));
var userName = driver.FindElementByName("userNameBox");

testWait.Until(pred => userName.Displayed);

This code fails due to the userName variable not being set (second line) – ‘An element could not be located on the page using the given search parameters.’

Obviously this is because the element isn’t loaded yet – which is the point of the code. But how else do I identify the element that I am looking for ahead of it being loaded?

Source: Windows Questions