我有一个ItemsControl对象绑定到ObservableCollection.
这是我的ItemsControl:
<ItemsControl x:Name="AvailableProjects" ItemsSource="{Binding ProjectsList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<CheckBox x:Name="IsProjectSelected" IsChecked="{Binding IsProjectSelected}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
这是我的ObservableCollection:
public ObservableCollection<ProjectInfo> ProjectsList { get; set; }
Run Code Online (Sandbox Code Playgroud)
我希望当用户按下checkBox时,observableCollection的"CollectionChanged"事件被触发但它不起作用.我注意到复选框项正在处理事件,似乎ObservableCollection没有注意到.有人可以帮我这个吗?提前致谢!