[转帖] WPF Designer Guide to Style LiveView
来源:互联网 发布:浪潮软件股票怎么样 编辑:程序博客网 时间:2024/05/16 06:18
[ReadMe] This article followed is referred from www.designerwpf.com/. All rights preserved.
So, after months of delay I finally figured that there are probably some people out there who want to figure out how to make the WPF listview look the way they want it to look.
A quick note: I will be dealing almost entirely with the listview look. If you want the listview to do something (functionality) or look a certain way and you can’t find the answer here, leave a comment with your suggestion and I’ll try to blog about it and place a link to the answer in my listview FAQ.
My goal is to create a significant repository on getting the stinking listview to look the way you want and do what you want it to do.
You’re probably here because, compared with most of the WPF controls, Blend gives very little guidance on how to deal with the listview (even though you use the listview for practically everything you do). So we’re going to start with the basic structure of the listview. This is what the basic listview looks like in the XAML.
<ListView>
<ListView.View>
<GridView>
<GridViewColumn Header=”Column Header“/>
</GridView>
</ListView.View>
</ListView>
So this post will start out giving basic guidance on what to edit when you’re trying to edit the various parts of the listview. I will update these sections with links and tutorials on listview specific tasks as time goes on.
As a point of note, I recommend using an ItemSource for your listview when you’re learning ot style it. Manually putting ListViewItems into it and trying to style them will muddy the waters of good design. If you need a good ItemsSource, I recommend any of the New York Times RSS feeds.
How to connect the New York Times RSS feed to your listview
Question 1: “How do I make the items (see picture below) look the way I want them to?”
Answer: Use the ItemContainerStyle property in the ListView (and the associated ControlTemplate)
More on ItemContainerStyle and Blend
In the XAML:
Put this in the resources:
<Style x:Key=”MyItemContainerStyle” TargetType=”{x:Type ListViewItem}“>
</Style>
Put this in the composition:
<ListView ItemContainerStyle=”{DynamicResource MyItemContainerStyle}“>
Question 2: “How do I make all the items in a certain column (see below) look a certain way?”
Answer: Use a CellTemplate in the GridViewColumn
More on CellTemplate and Blend.
In the XAML:
Put this in the resources:
<DataTemplate x:Key=”MyCellTemplate” >
</DataTemplate>
Put this in the composition:
<GridViewColumn CellTemplate=”{DynamicResource MyCellTemplate}“>
Question 3: “How do I make the whole header (see below) look the way I want?”
Answer: Use the ColumnHeaderContainerStyle in the GridView (and the associated ControlTemplate)
More on the ColumnHeaderContainerStyle and Blend
In the XAML:
Put this in the resources:
<Style x:Key=”MyColumnHeaderContainerStyle” TargetType=”{x:Type GridViewColumnHeader}“>
</Style>
Put this in the composition:
<GridView ColumnHeaderContainerStyle=”{DynamicResource MyColumnHeaderContainerStyle}“>
Question 4: “How do I change the layout of the header sections (all of them)?”
Answer: Use a ColumnHeaderTemplate in the GridView
How do I get to the ColumnHeaderTemplate using Blend? (coming soon)
In the XAML:
Put this in the resources:
<DataTemplate x:Key=”MyColumnHeaderTemplate” >
</DataTemplate>
Put this in the composition:
<GridView ColumnHeaderTemplate=”{DynamicResource MyColumnHeaderTemplate}“>
Question 5: “How do I make a specific part of the header look different than another part?”
or “How do I make the red part look different than the blue part?”
Answer: Use the HeaderTemplate in the GridViewColumn
How do I get to the HeaderTemplate using Blend? (coming soon)
In the XAML:
Put this in the resources:
<DataTemplate x:Key=”MyHeaderTemplate“>
</DataTemplate>
Put this in the composition:
<GridViewColumn HeaderTemplate=”{DynamicResource MyHeaderTemplate}“>
Original url for your reference: http://www.designerwpf.com/2007/12/06/the-wpf-designers-guide-to-styling-the-your-favorite-adjectival-swear-word-here-listview/
- [转帖] WPF Designer Guide to Style LiveView
- Web Designer's Guide to Adobe Photoshop
- Style Guide
- Writing Scientific Software: A Guide to Good Style
- wpf Style
- FW: C++ Style Guide : C++ Style Guide
- Good example to learn WPF style and template.
- C# Coding Style Guide
- C# Coding Style Guide
- C# Coding Style Guide
- Mozilla Coding Style Guide
- C# Coding Style Guide
- X.509 Style Guide
- Dojo Style Guide(存照)
- C++ Style Guide
- Google C++ Style Guide
- Google C++ Style Guide
- Google C++ style guide
- _TrackMouseEvent的用法
- 100Mbit/sFull与auto协商为100Mbit/sHalf
- WSDL学习(二)
- 请各位大哥大姐指点
- Servlet实现文件下载
- [转帖] WPF Designer Guide to Style LiveView
- Subversion服务器搭建 svn服务器搭建
- 哎呀,Java!
- Windows下配置SVN 1.4.5 + APACHE 2.2.6使用域认证
- [托业]TOEIC词汇汇总(完整篇)2
- 我们不是心理医生
- usb mass storage设备枚举过程
- 修改Java文件后终于不用重启服务器了
- pku 3687