加载网格后,如何获取Silverlight Datagrid的行数? [英] How do I get Silverlight Datagrid row count after grid is loaded?

查看:65
本文介绍了加载网格后,如何获取Silverlight Datagrid的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将列表设置为NEW时,我得到"O"数据.目前没有数据.

When I set the list to NEW, I get ''O'' data. Currently getting no data.

Private Sub ContctDomainDataSource_LoadedData(ByVal sender As System.Object, ByVal e As System.Windows.Controls.LoadedDataEventArgs) Handles ContctDomainDataSource.LoadedData
        ActivityDisplay.IsActive = False

        Dim _lst As List(Of Contct)()
        ContctDataGrid.ItemsSource = _lst
        Dim iRowCount As Integer = _lst.Count()

        CountBox1.Text = _lst.Count

        If e.HasError Then
            System.Windows.MessageBox.Show(e.Error.ToString, "Load Error", System.Windows.MessageBoxButton.OK)
            e.MarkErrorAsHandled()
        End If
    End Sub


我发现一则帖子显示该项目计数已合并到域服务中.但是我仍然没有解决在文本框中显示计数的问题.


I found a post that shows that item count has been incorporated in the Domain Service. But I still haven''t resolved displaying the count in a textbox.

Dim loadCustomer As EntityQuery(Of Customer_Profile2) = Domaincontext.GetCustomerProfileQuery() loadCustomer.IncludeTotalCount = True
Dim loadOp = Domaincontext.Load(Of Customer_Profile2)(loadCustomer).TotalEntityCount



http://blogs.msdn.com/b/deepm/archive/2010/03/18/count-t.aspx?CommentPosted=true#commentmessage



http://blogs.msdn.com/b/deepm/archive/2010/03/18/count-t.aspx?CommentPosted=true#commentmessage

推荐答案

看起来您正在创建一个空列表,然后将网格上的项目源设置为该空列表.但是,创建空列表时通常不使用"new"关键字吗?为何您希望空列表的计数不为零?
Looks like you are creating an empty list, then setting the items source on the grid to that empty list. Though, wouldn''t you usually use the "new" keyword when creating an empty list? And why would you expect the count of an empty list to be anything but zero?


简单地显示数据网格的基础集合的计数-这应该是您所要的.
Simply display the count of the datagrid''s underlying collection - that should be what you are looking for.


<pre lang="vb">If (DataGrid.ItemsSource IsNot Nothing) Then
            Dim count As Integer = DataGrid.ItemsSource.OfType(Of Object)().Count()
            lblCount_Gen.Content = "Count: " & count
        End If



这篇关于加载网格后,如何获取Silverlight Datagrid的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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