B
B
BadCats2017-06-22 15:29:20
WPF
BadCats, 2017-06-22 15:29:20

Add a button to each item in ElementTab - dynamically?

private void NewHolstButton_Click(object sender, RoutedEventArgs e)
        {
            object newItem = new Image () ;
           
            ElementTab.Items.Add(newItem);

            
            for (int i= (int)ZeroItem.Tag; i <= ElementTab.Items.CurrentPosition; i++)
            {
                //добавлять кнопку на каждый item
                
            }
           
           
        }

        
    }

There is an ElementTab on the form - inside of which an Item is added - the name is ZeroItem. Inside this ZeroItem - there is a button. The handler for this button is shown above.
On button click I create new Items for ElementTab - adding them to the collection of
ZeroItem elements - assigned a Tag - Tag="1" which I use as counter
for (int i= (int)ZeroItem.Tag; i <= ElementTab.Items.CurrentPosition; i++)

- as if binding it to the first element - where the button for creating the next Items is contained.
Now in this cycle I want to make sure that on each Item created - also dynamically - a button is added "automatically".

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question