Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7081931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:58:58+00:00 2026-05-28T06:58:58+00:00

<StackPanel Name=stTeam2 Width=40 > <Button Click=Team2_Click Height=55 Name=btn1T2 Width=30>T1</Button> <Button Click=Team2_Click Height=55 Name=btn2T2 Width=30>T2</Button>

  • 0
 <StackPanel Name="stTeam2" Width="40" >
     <Button Click="Team2_Click"  Height="55" Name="btn1T2" Width="30">T1</Button>
     <Button Click="Team2_Click" Height="55" Name="btn2T2" Width="30">T2</Button>
     <Button Click="Team2_Click" Height="55" Name="btn3T2" Width="30">T3</Button>
     <Button Click="Team2_Click" Height="55" Name="btn4T2" Width="30">T4</Button>
     <Button Click="Team2_Click" Height="55" Name="btn5T2" Width="30">T5</Button>
     <Button Click="Team2_Click" Height="55" Name="btn6T2" Width="30">T6</Button>
     <Button Click="Team2_Click" Height="55" Name="btn7T2" Width="30">T7</Button>
 </StackPanel>

Is it possible to find the Button control Based on content.

If T5 is specified can we find the control btn5T2 in the stackpanel?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:58:59+00:00Added an answer on May 28, 2026 at 6:58 am

    Yes you can…Although entirely inefficient way to develop WPF software.
    Since you gave your StackPanel a name in the XAML you can access it from the Code-Behind

    Code Behind

    for (int i = 0; i < stTeam2.Children.Count; i++)
    {
        if (stTeam2.Children[i].GetType() == typeof(Button))
        {
            Button currentButton = (Button)stTeam2.Children[i];
            if (currentButton.Content.ToString().Equals("T4"))
            {
                // Do something
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<ListBox Height=434 HorizontalAlignment=Left Margin=6,238,0,0 Name=listBox1 VerticalAlignment=Top Width=432 DataContext={Binding}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text={Binding Name}
I've got some RadioButtons in my XAML... <StackPanel> <RadioButton Name=RadioButton1 GroupName=Buttons Click=ButtonsChecked IsChecked=True>One</RadioButton> <RadioButton
I have a GridView control: <GridView> <GridViewColumn Header=Name Width=500> <GridViewColumn.CellTemplate> <DataTemplate> <StackPanel Orientation=Horizontal> </StackPanel>
I have a vertical StackPanel with two elements: a Button and a ListBox. How
How can I constrain a vertical WPF StackPanel 's width to the most narrow
I have xaml that lookes like this <ListBox> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text={Binding Name}
I have a databound and itemtemplated ListBox: <ListBox x:Name=lbLista ScrollViewer.VerticalScrollBarVisibility=Visible> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation=Horizontal>
<Border CornerRadius=2,2,2,2 BorderThickness=1 BorderBrush=LightSkyBlue Margin=5,2,2,2 x:Name=PersonBorder Visibility=Collapsed> <StackPanel Orientation=Vertical> <ListBox Name=personListBoxTest BorderThickness=0 ScrollViewer.HorizontalScrollBarVisibility=Hidden ScrollViewer.VerticalScrollBarVisibility=Auto
I have a form: <StackPanel x:Name=LayoutRoot> <sdk:ValidationSummary /> <sdk:Label Target={Binding ElementName=Greeting} /> <TextBox x:Name=Greeting
I have a Stackpanel and want that the items automatically set their sizes regarding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.