Search code examples
wpftextblock

How to clear TextBlock


I'm adding text TextBlock Text1,Text2,Text3 in Adddata() function as follow.

if (i == 0)
{
    Text1.Text = tagname.AlarmTag;
}
if (i == 1)
{
    Text2.Text = tagname.AlarmTag;
}
if (i == 2)
{
    Text3.Text = tagname.AlarmTag;
}

Now in deletedata() I want to clear all contents in three textblock. How can I do that? Because I cannot find Clear option. I want to clear text of three textblock at a time.


Solution

  • To "clear" the data :

    Text1.Text = String.Empty;
    Text2.Text = String.Empty;
    Text3.Text = String.Empty;