随笔 - 55  文章 - 15  trackbacks - 0
<2012年10月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

      
      GridView这个东西可以接受一个集合(一个组Group),也可以一个包含集合的集合(多个Group)。ListView是一样的道理。GridView有诸多的属性,有的是关于Item的,包括Item的DataTemplate,即一个项中的数据如何排列,有的是多个Items的,包括ItemsPanel,即多个Item怎么在一个Panel中配列,有的是多个Group的,Group怎么排列,等等,我只将我遇到的问题,接触到的问题阐述一下,其他的东西慢慢研究。
      老套路,先上个图吧。自己总结的各个属性都代表了什么意思,设置哪一块的。
     
这里是讲述了一个GridView中有两个Group的情况,每个Group中又有三个Items。
另外,因为之前我们一直在捣鼓不同的DataTemplate,所以这里的一个Group里面有两个DataTemplate,左边的大的占单独一列,其他两个占一列。这里需要注意一下:

设置规律:
       如果在GroupStyle.Panel里面设置了ItemHeight  ItemWidth,并且设置了MaxColumOrRow的话,会自动计算,比如设置了100,200,5的话,那么现在算出来,这个Group的宽是1000,高是500,如果同时在GroupStyle.Container里面设置的<Setter Property="Width" value="1000"/> <Setter Property="Heigh" Value="500"/>的话,那么刚合适。
       如果Container里面设置的是width=800, height=400的话,将会有一部分不会显示.
       如果你在Container里面没有设置Width和height的话,那么,如果竖着装不下的话,它会查看横着能不能装下,如果可以就横着装,如果不行,一部分不显示。

以下部分是在之前练习GridView分组的时候
GroupStyle: Describes how to display the grouped items in a collection. If a gridview have two groups, this groupstyle is purposed to display how these two gropu display in gridview. It has some properties need to be setted in XAML file.

ContainerStyle: Gets or sets style that is applied to the GroupItem genarated or each item. Means set each groups border, margin, or background e.t.
HeaderTemplate: Gets or sets the template that is used to display the group header.
HidesIfEmpty : indicates whether items corresponding to empty groups should be display.
Panel: a template that creates the panel used to lay out the items.
It looks like similar with ItemsPanel, because the definition is:
property ItemsPanelTemplate^ Panel{
    ItemsPanelTemplate^ get();
    void set(ItemsPanelTemplate^ value);
}
But even this, they're different.
I'v try modify <GroupStyle.Panel><ItemsPanelTemplate><VeriableGrid ...></..></..>. It didn't affect the items layout in a Group.
Other wise, If you modify ItemsPanel, a property of GridView, you can obviously notify the difference. 
So my suggestion is if you want change layout of items, just use ItemsPanel="{StaticResource someTemplate}".

if you set a Itemspanel and then you also set a  GroupStyle.Panel, you will got a wrong layout. Seggestion is set GoupStyle and don't set ItemsPanel


<local:VariableSizedWrapGridView.ItemContainerStyle>
                <Style TargetType="GridViewItem">
                    <Setter Property="Background" Value="Red"/>
                    <Setter Property="BorderBrush" Value="Green"/>
                    <Setter Property="BorderThickness" Value="5"/>
                    <Setter Property="Margin" Value="60"/>
                    <Setter Property="Foreground" Value="Black"/>
                    <Setter Property="Name" Value="Hello"/>
                </Style>
            </local:VariableSizedWrapGridView.ItemContainerStyle>


今天暂且到这里,明天再把这章好好整理一下。实在不想弄了。下一章结合着如何实现GridView的分组分析一下GridView。
      
posted on 2012-10-18 21:29 Dino-Tech 阅读(966) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理