Here's a working example, based on your XAML:
First of all, the code-behind:
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Documents;
namespace WpfApplicationCheckBoxList
{
public partial class Window1 : Window, INotifyPropertyChanged
{
#region Instance Variables
List<checklistitem> checkList;
#endregion /Instance Variables
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
{
PropertyChanged(this, e);
}
}
#endregion /INotifyPropertyChanged
public Window1()
{
InitializeComponent();
CheckList = GenerateTestData();
}
public List<checklistitem> CheckList
{
get { return checkList; }
set { checkList = value; this.OnPropertyChanged(new PropertyChangedEventArgs("CheckList")); }
}
List<checklistitem> GenerateTestData()
{
List<checklistitem> checkListItems = new List<checklistitem>();
checkListItems.Add(new CheckListItem { TheText = "My Text Here 1", IsSelected = false });
checkListItems.Add(new CheckListItem { TheText = "My Text Here 2", IsSelected = true });
checkListItems.Add(new CheckListItem { TheText = "My Text Here 3", IsSelected = false });
return checkListItems;
}
}
}
Remember to set the DataContext in your XAML:
<window x:class="WpfApplicationCheckBoxList.Window1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1"
Height="400"
Width="600"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<grid>
<listbox x:name="listExtraSkills" itemssource="{Binding CheckList}" grid.column="1" grid.row="6" height="50">
<listbox.itemtemplate>
<datatemplate>
<checkbox name="chkitems" content="{Binding TheText}" ischecked="{Binding IsSelected }"></checkbox>
</datatemplate>
</listbox.itemtemplate>
</listbox>
</grid>
</window>
And finally the data object you're binding to the list:
public class CheckListItem
{
public string TheText { get; set; }
public bool IsSelected { get; set; }
}