Hello I'm trying to do a foreach loop that will create an itemscontrol with an image, a textblock and 2 buttons as child of another itemscontrol. I want to have the textblock.text of the textblock as the string in the loop.
Xaml:
<Grid>
<ItemsControl x:Name="MainControl" Margin="0,175,0,22">
<ItemsControl Margin="10,0,0,0" Style="{StaticResource HorizontalItemsControl}">
<Border Background="Black" BorderBrush="#FF1EF3F3" BorderThickness="2">
<Image Height="50" Width="50" Source="{StaticResource SoulsRebornFlame}"/>
</Border>
<TextBlock VerticalAlignment="Center" x:Name="PendingUsername" FontSize="18" Text="Username" FontFamily="Segoe UI Black" Margin="15,0,0,0" Foreground="White"/>
<Button Margin="15,0,0,0" Style="{StaticResource MyButtonStyle}">
<TextBlock VerticalAlignment="Center" FontSize="18" Text="V" FontFamily="Segoe UI Black" Foreground="Lime"/>
</Button>
<Button Margin="15,0,0,0" Style="{StaticResource MyButtonStyle}">
<TextBlock VerticalAlignment="Center" FontSize="18" Text="X" FontFamily="Segoe UI Black" Foreground="Red"/>
</Button>
</ItemsControl>
</ItemsControl>
</Grid>
c#
foreach(string senderusername in dataCollection)
{
//Create new itemscontrol with the childs and set the textblock.text equal to snederusername.
}
So i want to programatically make the xaml objects foreach string int the list dataColletion.
How do i do this ? Thanks in advance.