zoukankan      html  css  js  c++  java
  • 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>

     结果如下:

  • 相关阅读:
    《软件需求十步走》阅读笔记一
    专业实训项目需求分析
    2015秋季学期个人阅读计划
    最后期限阅读笔记3
    最后期限阅读笔记2
    最后期限阅读笔记1
    你的灯亮着么阅读笔记3
    DPDK(二):准备知识7---linux虚拟网络设备
    DPDK(二)准备6---PMD
    DPDK(二):准备知识4 --- 无锁FIFO环形队列
  • 原文地址:https://www.cnblogs.com/yghost/p/2377920.html
Copyright © 2011-2022 走看看