开发者

GridView hide Items area

I want to hide the items area of a GridView, so that only the columns headers are visible. The part below the column headers should be invisible (collapsed). Here is my futile attempt:

      <ListView ItemsSource="{Binding .}">
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Height="0" Visibility="Collapsed"></StackPanel>
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>

        <ListView.View>
            <GridView>
                <GridViewColumn Header="Name"  />
       开发者_StackOverflow         <GridViewColumn Header="Size" />
                <GridViewColumn Header="Date"  />

            </GridView>
        </ListView.View>
    </ListView>

So my question is, how can I hide the items area (the part below the column headers) of the gridview


In listview, headers are shown using a GridViewHeaderRowPresenter. If you want to show only a header row, try to use this object in which you list the columns you need. With your example:

EDIT

//resources
<Window.Resources>
    <GridViewColumnCollection x:Key="HeaderColumns">
        <GridViewColumn Header="Name"  />
        <GridViewColumn Header="Size" />
        <GridViewColumn Header="Date"  />
    </GridViewColumnCollection>
</Window.Resources>

//in layout
<GridViewHeaderRowPresenter  Columns="{StaticResource HeaderColumns}" />

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜