Databound ListView with CheckBoxes and handling IsChecked property in WPF.


Hi everyone!
I'm trying to develop something like this...
I have WPF application with user logging enabled. And when creating a user for the system; the Admin have to choose what are the departments that the new user could work for. So there is a ListView that showing available departments to choose (by checking the relevant checkboxes of departments). And the selection of departments should be easy (when selecting a row, its CheckBox should be checked. And it's now OK.)
My problems are;
  1. How to get IsChecked or IsSelected items (CheckBoxes) in the ListView through a loop.
  2. When an existing user is selected; I want to display all the departments on the ListView with previously selected departments are already selected.
    Please help me at this. This is the ListView.
<ListView ItemsSource="{Binding}" Name="lvDepartments" SelectionMode="Multiple">
<GridView AllowsColumnReorder="False">
<CheckBox VerticalAlignment="Center"
IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}">
<TextBlock Text="{Binding DepID}" Width="0"/>
<GridViewColumn DisplayMemberBinding="{Binding DepID}" Header="DepartmentID" Width="0" >
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Department" Width="340" />