Need to add a
RegisterName
call:
RegisterName("TextBlock1", Var_TextBox);
FindName operates within the current element's namescope. Any additions to the element tree after initial loading and processing must call the appropriate implementation of RegisterName for the class that defines the XAML namescope.
Otherwise, the added object cannot be referenced by name through methods such as FindName. Merely setting a Name property (or x:Name Attribute) does not register that name into any XAML namescope. Adding a named element to an element tree that has a XAML namescope also does not register the name to the XAML namescope.
The most common scenario for application developers is that you will use RegisterName to register names into the XAML namescope on the current root of the page.