排序数据网格时的延迟

时间:2016-09-30 15:08:39

标签: c# wpf performance sorting datagrid

我有一个包含5列和60行的WPF数据网格。 当我按行列标题对行进行排序时,会有一些延迟时间。如果我使用winform数据网格对相同的项目进行排序,那就快得多了。

这是我的绑定代码和我的XAML定义:

        public System.Data.DataTable Users{ get; set; }
    public UsersView(IUserRepository userRepository)
    {
        Repository = userRepository;
        InitializeComponent();
        Users = Repository.GetAll();
         usersDataGrid.DataContext = Users;
    }


<UserControl x:Class="FundTrading.UsersView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:FundTrading.Views"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300" Height="Auto" Width="Auto">

    <DataGrid  IsReadOnly="true" SelectionMode="Single"   AutoGenerateColumns="False" x:Name="usersDataGrid" ItemsSource="{Binding}" HorizontalGridLinesBrush="Lavender" VerticalGridLinesBrush="Lavender" RowBackground="LightYellow" >

        <DataGrid.Columns>
            <DataGridTextColumn Header="Id"  Binding="{Binding UserId}" Width="100" />
        <DataGridTextColumn Header="Login Id" Binding="{Binding LoginName}" Width="100" />
        <DataGridTextColumn Header="Name" Binding="{Binding Description}" Width="300" />
        <DataGridTextColumn Header="Active" Binding="{Binding Active}"  Width="100" />
        <DataGridTextColumn Header="Role"  Binding="{Binding RoleName}" Width="300" />
    </DataGrid.Columns>


</DataGrid>

WPF真的比Winform慢,还是我错过了什么?

非常感谢

0 个答案:

没有答案