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

  • SEARCH
  • Home
  • 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 7430397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:08:00+00:00 2026-05-29T09:08:00+00:00

I filled the icBoard with 50 Cell objects, so each Rectangle object has Cell

  • 0

I filled the icBoard with 50 Cell objects, so each Rectangle object has Cell as data object. Now, I want according to index or cell object to get the corresponding Rectangle element. For example I want to get the Rectangle in index=15. Not it’s data but the Rectangle itself.

How I can do this?

        public MainPage()
        {
            InitializeComponent();

            var cells = new List<Cell>();    
            for (int i = 0; i < 50; i++)
            {
                cells.Add(new Cell());
            }    
            icCells.ItemsSource = cells;
        }
       public void sector_Tap(object sender, System.Windows.Input.GestureEventArgs e)
       {
            //some code
            //....
            var tappedRectangle = (sender as Rectangle);
            var spesificRectangle = SOMEHOW_GET_RECTANGLE_AT_POSITION_15;
       }
    <ItemsControl Name="icBoard" Grid.Column="0" Margin="0">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Rectangle  Fill="#501e4696" Width="30" Height="30" Margin="1" Tap="sector_Tap" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <toolkit:WrapPanel />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
  • 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-29T09:08:02+00:00Added an answer on May 29, 2026 at 9:08 am

    I believe this might work:

    ContentPresenter contentPresenter = itemsControl.ItemContainerGenerator.ContainerFromIndex(15) as ContentPresenter;
    Rectangle rectangle= FindVisualChild<Rectangle>(contentPresenter );
    if (rectangle != null)
    {
    
    }
    
    public static T FindVisualChild<T>(DependencyObject depObj) where T : DependencyObject
    {
        if (depObj != null)
        {
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
            {
                DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
                if (child != null && child is T)
                {
                    return (T)child;
                }
    
                T childItem = FindVisualChild<T>(child);
                if (childItem != null) return childItem;
            }
        }
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSMutableArray filled with Task objects. I want to be able to
I have two NSMutableArray filled with data object. how do I compare both array
I filled a QString object with Unicode data and tried to send it with
I have a table filled with bus stops. Each stop has a line_id ,
I have a ListView filled with for loop. The data inside ListView is now
I have a grid filled with some data in my silverlight4 app. I want
I filled up a combobox with the values from an Enum. Now a combobox
I have a container filled with pairs. I want to iterate in it using
I have filled List<Object1> Object 1 contain 2 fields (int id & string name)
How can I draw a filled rectangle in an applet with half opacity/transparency?

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.