对不起,模糊的标题,我不能想出一个很好的方式来总结正在发生的事情。ListSelect SelectionMode = Extended
我有一个绑定的WPF列表框:
<UserControl.Resources>
<DataTemplate DataType="{x:Type local:MyBoundObject}">
<TextBlock Text="{Binding Label}" />
</DataTemplate>
</UserControl.Resources>
<ListBox ItemsSource="{Binding SomeSource}" SelectionMode="Extended">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
我只想选择的项目进行操作。我通过迭代所有项目的列表并检查每个对象来查看它是否设置了IsSelected属性。
这个工作除了当我有很多项目在列表(足够,所以他们都不可见),我按CTRL-A选择所有项目。当我这样做时,所有可见项都将其IsSelected属性设置为true,其余所有项都保留为false。只要向下滚动,其他项目就会进入视图,然后将其IsSelected属性设置为true。
有没有什么办法可以解决这个问题,以便在按下CTRL-A时每个对象的IsSelected属性都设置为true?
这工作!谢谢! – ConditionRacer 2012-08-24 18:31:17