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()
}
}