I have a set of dynamically generated WPF control. How can I assign the Tag property of these controls dynamically? I created the controls like this:
SchlEntities db = new SchlEntities();
InitializeComponent();
var controls = from stud in db.Students
orderby stud.GroupID
group stud by stud.GroupID into gr
select gr;
foreach (var gr in controls)
{
CreateComboBox();
}
private void CreateComboBox()
{
ComboBox combox = new ComboBox();
combox.Width = 280;
combox.Height = 30;
combox.Background = Brushes.LightBlue;
combox.Margin = new Thickness(5);
stackpanel.Children.Add(combox);
}