I have a listbox in which the item source contains a List(of T) that has a SelectedFlag boolean property. My viewmodel is set as the DataContext of my user control and everything is working as expected except I can't get the property change even when a check box is changed.
Here is my xaml ListBox
<ListBox x:Name="lstRole" ItemsSource="{Binding Path=FAccountFunctions, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Id">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Path=SelectedFlag, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" />
<TextBlock Text="{Binding Path=FunctionDesc}" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I need to call my Filter() function after a check box is checked and I normally would set the UpdateSourcTrigger=PropertyChanged to make this work.
Public Property FAccountFunctions As List(Of FunctionType)
Get
Return _faccountFunctions
End Get
Set(ByVal value As List(Of FunctionType))
_faccountFunctions = value
Filter()
End Set
End Property
The PropertyChangedEvent is getting raised on the 'SelectedFlag' property in the FAccountFunctions collection. How can I raise an event on the items source when one of the properties SelectedFlag changes?
Changed my FAccountFunctions property to an ObservableCollection...no luck.
You'll need to make your Collection's CollectionChanged event fire when your Item's PropertyChanged event fires.
Something like:
...
...