如果不是真的很深:
清除:从TextBox中删除内容,并可能删除与其分配的资源
代码语言:javascript运行复制 public void Clear()
{
using (this.TextSelectionInternal.DeclareChangeBlock())
{
this.TextContainer.DeleteContentInternal(this.TextContainer.Start, this.TextContainer.End);
this.TextSelectionInternal.Select(this.TextContainer.Start, this.TextContainer.Start);
}
}将空字符串(因为string.Empty和"“相等)分配给Text属性,只需将空字符串赋值给附加属性TextBox.TextProperty:
代码语言:javascript运行复制public string Text
{
get
{
return (string) this.GetValue(TextBox.TextProperty);
}
set
{
this.SetValue(TextBox.TextProperty, (object) value);
}
}