dimanche 2 août 2015

wpf binding several checkboxes' ischecked to static list

This is a re-cap of the second part of a question I posted, and understanding that putting two questions in one entry is not playing nice, here goes:

I am programmatically creating several checkboxes and adding them to a StackPanel named myStackPanel, using a foreach loop. I can change that to any other type of construction (an array, for example):

foreach (something)
{
    CheckBox newCheckBox = new CheckBox();
    myStackPanel.Children.Add(newcheckBox);
}

on the text side there's a non-static class myClass with a static property myStaticList:

public class myClass
{
    public static ObservableCollection<bool> myStaticList { get; set; }
}

I'd like to bind the isChecked of the dynamically-created checkboxes to myStaticList. I have no idea how to do this.

Help please! TIA




Aucun commentaire:

Enregistrer un commentaire