我有一个列表框,其中项目源包含一个具有 SelectedFlag 布尔属性的 List(of T)。我的视图模型被设置为我的用户控件的 DataContext 并且一切都按预期工作,但即使更改了复选框,我也无法更改属性。
这是我的 xaml 列表框
<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>
在选中复选框后,我需要调用我的 Filter() 函数,我通常会设置 UpdateSourcTrigger=PropertyChanged 以使其工作。
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
在 FAccountFunctions 集合中的“SelectedFlag”属性上引发了 PropertyChangedEvent。当 SelectedFlag 属性之一发生更改时,如何在项目源上引发事件?
将我的 FAccountFunctions 属性更改为 ObservableCollection ......不走运。