'Razor component instances created in loop - parameters problem

I would like generate instances of component like these:

            for (int i = 0; i < 10; i++)
            {
                <MyComponent Index="@i">
                    @i
                </MyComponent>
            }

Problem is that every component instance has in final view the same value of param Index, and this value is 9. It si probably because this is right variables value when render time. Is it possible to pass right value of "i" variable to components? Thanks very much.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source