0

I have a ListBox defined as follows. I have CheckBox inside the ListView item which needs to be checked/unchecked programmatically (just wanted to implement a select/deselect all operation). What's the best way to achieve this?

<ListBox Margin="0,0,10,0" Name="listViewChanges" SelectionMode="Multiple">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                <CheckBox x:Name="lblChangedSelected" IsChecked="{Binding Selected}" VerticalAlignment="Center" VerticalContentAlignment="Center" Margin="10,0,0,0"></CheckBox>
                <Label x:Name="lblChangedStatus" Content="{Binding Status}" VerticalContentAlignment="Center"></Label>
                <Label x:Name="lblChangedPath" Content="{Binding Path}" VerticalContentAlignment="Center"></Label>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
Lucas
  • 3,376
  • 6
  • 31
  • 46
sarat
  • 10,512
  • 7
  • 43
  • 74

1 Answers1

2

You should have the class that's behind the binding implement INotifyPropertyChanged. Then, when you change the property, fire the NotifyPropertyChanged event and the binding should update automatically.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • I am new to WPF. Can you give some resources/links? – sarat Dec 06 '12 at 16:34
  • 2
    This is not WPF specific (at least not the part about `INotifyPropertyChanged`). Try this: http://stackoverflow.com/questions/6789236/how-does-wpf-inotifypropertychanged-work – Thorsten Dittmar Dec 06 '12 at 16:35