1

我的程序中有datagrid。那个datagrid 包含大约1000 行。当我滚动滚动条时,它的工作非常缓慢,并且不会让用户看到没有爆炸的数据。这是数据网格的定义:(在 xmal 中)

      <DataGrid RowHeight="18" ColumnHeaderHeight="22" AlternationCount="2" AutoGenerateColumns="False" Margin="196,62,8,69" Name="dgItems" HeadersVisibility="All"  Loaded="dgItems_Loaded" Opacity="50" ItemsSource="{Binding}" MouseRightButtonDown="dgItems_MouseRightButtonDown" MouseDoubleClick="DataGrid_MouseDoubleClick" CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True" AllowDrop="True" MouseLeftButtonDown="dgItems_MouseLeftButtonDown" Drop="dgItems_Drop" DragEnter="dgItems_DragLeave" PreviewMouseRightButtonDown="dgItems_PreviewMouseRightButtonDown" AlternatingRowBackground="#AC87CEFA" KeyDown="dgItems_KeyDown" EnableColumnVirtualization="True" IsTextSearchEnabled="True" GridLinesVisibility="None">
        <DataGrid.Background>
            <ImageBrush ImageSource="/MyUI;component/Images/User.png" Stretch="None" TileMode="None" />
        </DataGrid.Background>
        <DataGrid.Columns>
            <DataGridTemplateColumn Header="" Width="5" CanUserReorder="False" CanUserSort="False" CanUserResize="False">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Grid Background="White">
                        <Button Content="" Name="btnAddit" Visibility="Visible" Height="13" Width="13" Click="btnAddIt_Click" ToolTip="Add to current playlist">
                            <Button.Background>
                                <ImageBrush ImageSource="/MyUI;component/Images/Add.png" />
                            </Button.Background>
                        </Button>
                        </Grid>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn Header="Title"  Binding="{Binding Title}"/>
            <DataGridTextColumn Header="Chapter" Binding="{Binding Chapter}" />
            <DataGridTextColumn Header="Number" Binding="{Binding Number}" />
            <DataGridTextColumn Header="Size" Binding="{Binding Size}" />
            <DataGridTextColumn Header="Language" Binding="{Binding Language}" />
            <DataGridTextColumn Header="Genre" Binding="{Binding Genre}" />
            <DataGridTextColumn Header="Rate" Binding="{Binding Rate}" />
            <DataGridTextColumn Header="Counter" Binding="{Binding Counter}" />
            <DataGridTextColumn Header="ReleaseDate" Binding="{Binding ReleaseDate}" />
            <DataGridTextColumn Header="InsertDate" Binding="{Binding InsertDate}" />
            <DataGridTextColumn Header="LastRead" Binding="{Binding LastRead}" />
        </DataGrid.Columns>
        <DataGrid.RowStyle>
            <Style TargetType="{x:Type DataGridRow}">
                <Setter Property="AllowDrop" Value="True" />
            </Style>
        </DataGrid.RowStyle>
    </DataGrid>
4

0 回答 0