【问题标题】:How can i add items to DataGrid when users scroll to the bottom?当用户滚动到底部时,如何将项目添加到 DataGrid?
【发布时间】:2012-03-09 07:41:57
【问题描述】:
   <DataGrid AutoGenerateColumns="False" Name="dgMain" 
              Grid.Column="0" Grid.Row="1"
              ItemsSource="{Binding Path=Items,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
        <DataGrid.Columns>
            <DataGridTextColumn Header="id" Binding="{Binding Path=Id,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
            <DataGridTextColumn Header="name" Binding="{Binding Path=Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
        </DataGrid.Columns>
    </DataGrid>

ItemsSource 绑定到public ObservableCollection<Student> Items { get; set; }

我很好初始化的项目

       Items = new ObservableCollection<Student>();

        for (int i = 0; i < 1000; i++)
        {
            Items.Add(new Student() { Id = i, Name = "name" + i.ToString() });
        }

如何让 dataGrid 首先显示 50 个项目,当用户滚动到底部时,我很好地加载了其他 50 个项目,然后。

1.scrollView 中没有滚动到底部事件,所以我怎样才能让滚动到底部?

2.当 itemsSource 有 1000 个项目时,如何让 dataGrid 显示 50 个项目?

【问题讨论】:

    标签: wpf datagrid scrollview


    【解决方案1】:

    没有内置分页,因此如果您想要 50 个项目,您只需要在源中有 50 个项目。

    DataGrid 支持虚拟化。为什么不只限制高度?高度=“200”。

    【讨论】:

      猜你喜欢
      • 2022-11-17
      • 2016-12-12
      • 1970-01-01
      • 2017-12-21
      • 2018-05-25
      • 2021-05-29
      • 2013-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多