C#/WPF:想法如何分别显示ListView的最后一行? [英] C#/WPF: Idea how to display the last row of a ListView separately?

查看:127
本文介绍了C#/WPF:想法如何分别显示ListView的最后一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有大约10个GridViewColumn和一个大约100行/行的ListView. 我想在ListView的底部显示总计"或摘要行.

I've a ListView with about 10 GridViewColumn's and about 100 Lines/Row. I'd like to display a "Total" or summary row at the bottom of the ListView.

有人知道如何做到这一点,同时保持ColumnWidth等其他属性并使其成为一个单独的项目,以便主" ListView可以具有滚动条吗?

Does anyone have a idea how to do that, with keeping the ColumnWidth etc. like the others and making it a separate item, so the "main" ListView can have a scrollbar?

我在这里上传了一个模型(对不起,我的图形人才很抱歉:-)):
图像

I've uploaded here a mock-up (sorry for my bad graphic talent :-)):
image

推荐答案

这是一个如何在列表视图的末尾显示总计区域的示例.列宽绑定在每列及其总列之间

This is an example on how to have a listview with totals area at the end. The column width are binded between each column and its total

 <Window x:Class="WpfApplication2.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="Window1"
        x:Name="ctl"
        Height="300"
        Width="300"> 
  <Window.Resources>

    <GridViewColumnCollection x:Key="gvcc">
      <GridViewColumn Width="{Binding Path=ActualWidth, ElementName=col1}"
                      Header="Date" />
      <GridViewColumn  Width="{Binding Path=ActualWidth, ElementName=col2}"
                       Header="Day Of Week"
                       DisplayMemberBinding="{Binding DayOfWeek}" />
      <GridViewColumn  Width="{Binding Path=ActualWidth, ElementName=col3}"
                       Header="Year"
                       DisplayMemberBinding="{Binding Year}" />

    </GridViewColumnCollection>
  </Window.Resources>

  <Grid>
    <DockPanel HorizontalAlignment="Stretch"
               VerticalAlignment="Stretch"
               LastChildFill="True">


      <GridViewRowPresenter Name="listview_total"
                            DockPanel.Dock="Bottom" 
                            Margin="0,5,0,5"
                            Columns="{StaticResource gvcc}">
        <GridViewRowPresenter.Content>
          <sys:DateTime>2005/2/1</sys:DateTime>
        </GridViewRowPresenter.Content>
      </GridViewRowPresenter>



      <ListView x:Name="listview_rows" 
                SelectionMode="Single"
                DockPanel.Dock="Top"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled">
        <ListView.View>
          <GridView>
            <GridViewColumn x:Name="col1"                            
                            Header="Date" />
            <GridViewColumn x:Name="col2"                            
                            Header="Day Of Week"
                            DisplayMemberBinding="{Binding DayOfWeek}" />
            <GridViewColumn x:Name="col3"                            
                            Header="Year"
                            DisplayMemberBinding="{Binding Year}" />
          </GridView>
        </ListView.View>

        <sys:DateTime>1/2/3</sys:DateTime>
        <sys:DateTime>4/5/6</sys:DateTime>
        <sys:DateTime>7/8/9</sys:DateTime>
        <sys:DateTime>10/11/12</sys:DateTime>
        <sys:DateTime>1/2/3</sys:DateTime>
        <sys:DateTime>4/5/6</sys:DateTime>
        <sys:DateTime>7/8/9</sys:DateTime>
        <sys:DateTime>10/11/12</sys:DateTime>
        <sys:DateTime>1/2/3</sys:DateTime>
        <sys:DateTime>4/5/6</sys:DateTime>
        <sys:DateTime>7/8/9</sys:DateTime>
        <sys:DateTime>10/11/12</sys:DateTime>
        <sys:DateTime>1/2/3</sys:DateTime>
        <sys:DateTime>4/5/6</sys:DateTime>
        <sys:DateTime>7/8/9</sys:DateTime>
        <sys:DateTime>10/11/12</sys:DateTime>
      </ListView>

    </DockPanel>
  </Grid>
</Window>

这篇关于C#/WPF:想法如何分别显示ListView的最后一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆