Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从常规项获取标签的值_C#_Wpf_Grid_Typeof - Fatal编程技术网

C# 从常规项获取标签的值

C# 从常规项获取标签的值,c#,wpf,grid,typeof,C#,Wpf,Grid,Typeof,我有一个带有标签和文本框的网格。 我想获取标签的内容。 如果您知道它是一个标签,则非常简单。 但这就是我所拥有的: foreach (var t in Grid1.Children) { if (t.GetType() == typeof(Label)) { string val = t.????; } } 如何获取此标签的内容?t.content.ToString()如何?不在那里。。。

我有一个带有标签和文本框的网格。
我想获取标签的内容。
如果您知道它是一个标签,则非常简单。
但这就是我所拥有的:

foreach (var t in Grid1.Children)
    {
         if (t.GetType() == typeof(Label))
         {
                string val = t.????;
         }
    }  

如何获取此标签的内容?

t.content.ToString()如何?不在那里。。。它只有tostring、gettype、gethashcode和equals关于t.Content.tostring()?不在那里。。。它只有tostring、gettype、gethashcode和equals
    foreach (var t in Grid1.Children)
    {
         if (t is Label)
         {
                string val = ((Label)t).Content.ToString()
         }
    }