The following code snippet is a button click event handler
and calls FindName method of Grid to find the control by its name. The code
takes control name from the TextBox and checks of the found control is a
TextBox, ListBox, or Button and based on its type, code sets its properties.

privatevoid FindNameButton_Click(object
sender, RoutedEventArgs e)

{

object item
= LayoutRoot.FindName(TextBox1.Text);

if (item isTextBox)

{

TextBox
txt = (TextBox)item;

txt.Text = "Aha!
you found me!";

txt.Background = newSolidColorBrush(Colors.LightYellow);

}

elseif (item isListBox)

{

ListBox
lst = (ListBox)item;

lst.Items.Add("Aha!
you found me!");

}

elseif (item isButton)

{

Button btn = (Button)item;

btn.Content = "Aha!
you found me!";

btn.Background = newSolidColorBrush(Colors.LightSeaGreen);

}

}

If you enter "TextBox1" in the TextBox and click Find By
Name button, you will see output like Figure 1.