foreach (UIElement oObject in this.LayoutRoot.Children)
{
Type type= oObject.GetType();
string name=oObject.GetValue(NameProperty).ToString();
if (type == typeof(TextBlock))
{
TextBlock textBlock = oObject as TextBlock;
if (textBlock != null)
{
MessageBox.Show(textBlock.Text);
}
}
if (type == typeof(TextBox))
{
TextBox textBox = oObject as TextBox;
if(textBox != null)
{
MessageBox.Show(textBox.Text);
}
}
if(type == typeof(ComboBox))
{
ComboBox comboBox = oObject as ComboBox;
if(comboBox != null)
{
MessageBox.Show(comboBox.SelectedItem.ToString());
}
}
if(type==typeof(Button))
{
Button button = oObject as Button;
if(button != null)
{
MessageBox.Show(button.Content.ToString());
}
}
}
}
No comments:
Post a Comment