【发布时间】:2010-10-25 20:28:37
【问题描述】:
有没有办法修改 UIElement 的内容?
我有这样的事情:
System.IO.FileStream rdr = System.IO.File.OpenRead(xamlFilePath);
System.Windows.UIElement uie = (System.Windows.UIElement)System.Windows.Markup.XamlReader.Load(rdr);
当我运行调试器并将 uie 添加到“Watch”窗口时,它给了我以下信息:
[-]uie
[-]System.Windows.Controls.Textbox {System.Windows.Controls.Textbox:Title}
<some stuff...>
Text "Title"
现在我需要能够做两件事:(1) 阅读文本框中的文本,以及 (2) 随时修改。
I was hoping for something in the lines of:
{
Textbox tb = (Textbox)uie.GetChild();
tb.Text = "New Title"
uie.SetChild(tb);
}
,但它不是那样工作的。如果有人能指出执行此功能的方法,我将不胜感激。
【问题讨论】:
-
请提供您的 XAML 文件的内容。