折腾了一早上的C# WPF ListView+Grid 实现图片+文字 自动换行排列 类似Windows资源管理器效果
<ListBox Name="lstFileManager" Background ="Transparent" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="10" Width="100" Height="120">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ></RowDefinition>
<RowDefinition Height="Auto" ></RowDefinition>
</Grid.RowDefinitions>
<Image Source="{Binding Pic}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="100"/>
<TextBlock Text="{Binding Name}" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Height="20"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
XAML
public class LVData
{
public string Name { get; set; }
public string Pic { get; set; }
}
ObservableCollection<LVData> LVDatas = new ObservableCollection<LVData>(); public void BindFileManager(){
lstFileManager.ItemsSource = LVDatas;
}
数据绑定
BindFileManager();
LVDatas.Add(new LVData { Name = "图片", Pic = "http://www.google.com/intl/en_ALL/images/logo.gif" });
LVDatas.Add(new LVData { Name = "图片", Pic = "http://www.google.com/intl/en_ALL/images/logo.gif" });
动态更改元素(先绑定数据 然后更改数据)

折腾了一早上的C# WPF ListView+Grid 实现图片+文字 自动换行排列 类似Windows资源管理器效果的更多相关文章
- WPF控件TextBlock中文字自动换行
原文:WPF控件TextBlock中文字自动换行 在很多的WPF项目中,往往为了追求界面的美观,需要控制控件中文字的换行显示,现对TextBlock控件换行的实现方式进行总结,希望大家多多拍砖!!! ...
- WPF实现Windows资源管理器(附源码)
今天我来写一篇关于利用WPF来实现Windows的资源管理器功能,当然只是局部实现这个功能,因为在很多时候我们需要来实现对本机资源的管理,当然我们可以使用OpenFileDialog dialog ...
- (C#)WPF:Grid面板介绍
Grid:网格面板 Grid和其他各个Panel比较起来,功能最多也最为复杂.要使用Grid,首先要向RowDefinitions和ColumnDefinitions属性中添加一定数量的RowDefi ...
- wpf ListView DataTemplate方式的鼠标悬停和选中更改背景色
今天使用wpf技术弄一个ListView的时候,由于需求需要,需要ListView显示不同的数据模板,很自然的使用了DataTemplate方式来定义多个数据模板,并在ListView中使用ItemT ...
- WPF ListView 选中问题
WPF ListView 选中问题 摘自:http://www.cnblogs.com/BBHor/archive/2013/04/28/VisualTreeHelper-PreviewMouseD ...
- [WPF]ListView点击列头排序功能实现
[转] [WPF]ListView点击列头排序功能实现 这是一个非常常见的功能,要求也很简单,在Column Header上显示一个小三角表示表示现在是在哪个Header上的正序还是倒序就可以了. ...
- WPF ListView 居中显示
原文:WPF ListView 居中显示 今天遇到的问题: 方法1:设置GridViewColumn的ActualWidth <ListView > <ListView.View&g ...
- WPF ListView控件设置奇偶行背景色交替变换以及ListViewItem鼠标悬停动画
原文:WPF ListView控件设置奇偶行背景色交替变换以及ListViewItem鼠标悬停动画 利用WPF的ListView控件实现类似于Winform中DataGrid行背景色交替变换的效果,同 ...
- WPF listview item mouse enter/over popup
This is because the routing strategy of the Loaded event is Direct, which means that the routed even ...
随机推荐
- Templates
Templates Templates are the site's markup, where images and js, css files are located as well as the ...
- MySQL(2):SQL语言的分类
SQL:Structured Query Language (结构化查询语言) 分类: 1.数据操作(管理)语言:直接对数据进行操作:(DML:Data Management Language) ...
- HeaderTemplate
前台代码: <asp:Repeater ID="rptList" runat="server" onitemdatabound="doSomet ...
- 为Debain &&Centos安装dig
Debain&Ubuntu sudo apt-get install dnsutils Fdeoar&Centos yum install bind-utils
- .net 并发
Nhibernate并发参考 http://www.cnblogs.com/lyj/archive/2008/10/21/1316269.html EF并发参考 http://www.cnblogs. ...
- 让aspx页面也可以通过url路由进行访问
参考文章:http://blog.csdn.net/zhanglong_longlong/article/details/8841030 这两天,在工作中需要将aspx的页面虚拟成url路径访问.比如 ...
- Sql Server Profiler保存与重演跟踪
重演跟踪的作用 可以将一个跟踪当做测试工具,当按照正确的顺序调用某些存储过程是肯能会重新生成特定的故障. 跟踪模板
- ###Maintainable C++
点击查看Evernote原文. #@author: gr #@date: 2014-08-15 #@email: forgerui@gmail.com 记录一些标准规范.让自己的编码更可读,更可维护. ...
- The method getContextPath() is undefined for the type ServletContext
我出错时,到网上说得是版本问题,我找到对应的包javax-servlet5.1.12.jar,把它删了,居然不报错了,原来是和包servlet-2_5-api.jar冲突了
- android中的4种点击事件
四种点击事件 (1)采用内部类的方式去实现OnClickListener (2)匿名内部类 (3)当前类imp OnClickListener (4)onclick ...