Caliburn Micro下轻松实现ListView的全选功能

Caliburn Micro是一个Caliburn精简版的开源框架,基于MVVM模式,可用于WPF, Silverlight, WP7等。有关它的具体介绍请看:

http://caliburnmicro.codeplex.com/

 

下面主要使用CM(Caliburn Micro)实现WPF的ListView全选功能,直接上码:

 1 <ListView Name= " lvFileCart " DockPanel.Dock= " Top " ItemsSource= " {Binding FileCart} " FontSize= " 12 " Height= " 150 ">
 2                 <ListView.ItemContainerStyle>
 3                     <Style TargetType= " ListViewItem ">
 4                         <Setter Property= " HorizontalContentAlignment " Value= " Stretch " />
 5                         <Setter Property= " IsSelected " Value= " {Binding IsSelected, Mode=TwoWay} "/>
 6                     </Style>
 7                 </ListView.ItemContainerStyle>
 8                 <ListView.View>
 9                     <GridView>
10                         <GridViewColumn Width= " 50 ">
11                             <GridViewColumn.CellTemplate>
12                                  <DataTemplate>
13                                      <CheckBox IsChecked= " {Binding IsSelected,RelativeSource={RelativeSource AncestorType=ListViewItem}} "  HorizontalAlignment= " Center " />
14                                  </DataTemplate>
15                             </GridViewColumn.CellTemplate>
16                              <HeaderedItemsControl>
17                                  <CheckBox cal:Action.Target= " {Binding ElementName=lvFileCart} " 
18                                            cal:Message.Attach= " [Event Checked]=[Action SelectAll]; [Event Unchecked]=[Action UnselectAll] "  />
19                              </HeaderedItemsControl>
20                         </GridViewColumn>
21                         <GridViewColumn Width= " 200 " Header= " Name " DisplayMemberBinding= " {Binding Path=FileName} "/>
22                         <GridViewColumn Width= " 100 " Header= " Size " DisplayMemberBinding= " {Binding Path=FileSize} "/>
23                         <GridViewColumn Width= " 200 " Header= " Path " DisplayMemberBinding= " {Binding Path=FilePath} "/>
24                     </GridView>
25                 </ListView.View>
26             </ListView>

 结果如下:

 

转载于:https://www.cnblogs.com/yghost/archive/2012/03/02/2377920.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值