wpf中listView多列显示

今天在项目中遇到需要分列显示数据列表,记录一下做法:

 

ExpandedBlockStart.gif 代码
 1    < ListView  BorderThickness ="0"  Margin ="10,0,0,0"     Name ="myNewListview"  Background ="Transparent"  ScrollViewer.VerticalScrollBarVisibility ="Hidden"   ItemsSource ="Myalllresouceist"
 2                                Width =" {Binding (FrameworkElement.ActualWidth),RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}} "
 3                                ItemContainerStyle =" {DynamicResource AllResourceListStyle} "  Visibility =" {Binding ElementName=listCB, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}} "   >
 4                                   < ListView.ItemsPanel >
 5                                   < ItemsPanelTemplate >
 6 
 7                                       < WrapPanel  ItemWidth ="100"  ItemHeight ="50"  IsItemsHost ="True"  Width =" {Binding ActualWidth,RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}} " />
 8 
 9                                   </ ItemsPanelTemplate >
10                               </ ListView.ItemsPanel >
11 
12                           </ ListView >

 

 

 

style正常写就行

 

 

ExpandedBlockStart.gif 代码
  < Style  TargetType ="ListViewItem"  x:Key ="AllResourceListStyle" >
            
< Setter  Property ="Template" >
                
< Setter.Value >
                    
< ControlTemplate  TargetType =" {x:Type ListViewItem} " >
                        
< StackPanel  Orientation ="Vertical" >
                            
< Button  Content =" {Binding ElementName} "  ToolTip =" {Binding ElementName} "  Style =" {StaticResource LinkButtonSytle} "  Width ="85"   Foreground ="#81CAFE"  Margin ="0,0,2,0"  Command ="Command:Commands.RunApplicationCommand"  CommandParameter =" {Binding} " ></ Button >
                            
< StackPanel  Orientation ="Horizontal" >
                                
< Image  Source =" {DynamicResource Login13x13} "  Width ="13"  Height ="13"  VerticalAlignment ="Center"  Margin ="5,0,0,0"   />
                                
< Image  Source =" {DynamicResource OperationPlan10x10} "  Width ="13"  Height ="13"  VerticalAlignment ="Center"  Margin ="5,0,0,0"   />
                                
< Image  Source =" {DynamicResource Close10x10} "  Width ="13"  Height ="13"  VerticalAlignment ="Center"  Margin ="5,0,0,0"   />
                            
</ StackPanel >
                        
</ StackPanel >
                    
</ ControlTemplate >
                
</ Setter.Value >
            
</ Setter >
        
</ Style >

 

 

ok了。

 

 

 

转载于:https://www.cnblogs.com/lichunliang/archive/2010/05/31/1748156.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值