Caliburn Micro下轻松实现ListView的全选功能
2012-03-02 23:57
417 查看
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>
结果如下:
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>
结果如下:
相关文章推荐
- 基于ListView和CheckBox实现多选和全选记录的功能
- 基于ListView和CheckBox实现多选和全选记录的功能
- 如何实现listView中checkbox的全选与反选功能
- BaseAdapter完美实现ListView中checkbox全选,取消,多选功能
- Android高级控件(一)——ListView绑定CheckBox实现全选,增加和删除等功能
- android ExpandableListView 实现全选,全不选,部分选中,不可选择的功能
- Android高级控件(一)——ListView绑定CheckBox实现全选,添加和删除等功能
- Android高级控件(一)——ListView绑定CheckBox实现全选,增加和删除等功能
- 基于ListView和CheckBox实现多选和全选记录的功能
- 基于ListView和CheckBox实现多选和全选记录的功能
- android 基于ListView和CheckBox实现多选和全选记录的功能(转)
- Android ListView条目全选功能,不用checkbox实现!
- Android高级控件(一)——ListView绑定CheckBox实现全选,增加和删除等功能
- ListView+CheckBox实现全选,全不选功能
- 基于ListView和CheckBox实现多选和全选记录的功能
- 基于ListView和CheckBox实现多选和全选记录的功能
- Android ListView条目全选功能,不用checkbox实现!
- 基于ListView的单选、全选、删除功能实现小Demo
- 基于ListView和CheckBox实现多选和全选记录的功能
- 基于ListView和CheckBox实现多选和全选记录的功能