Generate a new control for each listed item

Asked

Viewed 60 times

0

Hello, based on the code below, I would like to know how to generate a new control( in my case a grid) for each existing item in my Listbox...

My Listbox:

<ListBox Height="380.585" Width="258.998">
   <ListBoxItem x:Name="i" Content="grade"/>
   <ListBoxItem x:Name="ii" Content="grade"/>
   <ListBoxItem x:Name="iii" Content="grade"/>
   <ListBoxItem x:Name="iv" Content="grade"/>
   <ListBoxItem x:Name="v" Content="grade"/>
</ListBox>

Explanation: The reason of the function is that I wish to use a Wrappannel to display graphic models for each item, and therefore... always exist the number of Grids corresponding to items in the list.

  • Thiago, in load you call a method that creates a new control, for each item. You could use foreach and create a new control dynamically. I believe this link will help you: https://stackoverflow.com/questions/27275502/how-to-dynamically-add-gridviews-side-by-side-using-asp-net-c-sharp

  • Thanks man, I got with your help too, try to post as a reply with more details to help others too and even improve what I learned, I mark as a response why your comment already contains a reply.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.