Is there a way to modify a UIElement's contents?

I have something like this:

System.IO.FileStream rdr = System.IO.File.OpenRead(xamlFilePath);
System.Windows.UIElement uie = (System.Windows.UIElement)System.Windows.Markup.XamlReader.Load(rdr);

And when I run the debugger and add uie to the "Watch" window, it gives me the following:

[-]System.Windows.Controls.Textbox          {System.Windows.Controls.Textbox:Title}
<some stuff...>
Text                                        "Title"

Now I need to be able to do two things: (1) read the Text in the textbox, and (2) modify it whenever I want.

I was hoping for something in the lines of:

Textbox tb = (Textbox)uie.GetChild();
tb.Text = "New Title"

, but it does not work like that. If anyone can point me to the method that performs this function I'd really appreciate it.

I think some more information is required. Post XAML markup. Maybe you can unbox (typecast) the UIElement.

Thank you for the reply. I was after the "typecasting" of the UIElement, but I didn't know how to do it at first. Someone finally gave me the code to do it:

if (uie is System.Windows.Controls.TextBox) 
	TextBox tb = (TextBox)uie; 
	tb.Text = "New title"; 

Slightly easier than what I had in the beginning, and it makes sense, since "TextBox" is a "UIElement."

This question has already been answered. Start a new discussion instead.