WPF Datagrid flickering issue

霸气de小男生 提交于 2019-12-05 13:49:07

I tried your code. It is so simple to databind the datatable directly and the flickering will go away :). just use ObjectMessageDataTable.DefaultView instead of View. Because somehow the View object itself is created everytime View is created and this causes the datagrid to initialise from the beginning.

 ItemsSource="{Binding Path=ObjectMessageDataTable.DefaultView, IsAsync=True, UpdateSourceTrigger=PropertyChanged}"

so change to

<DataGrid
        Grid.Row="1"
        Width="Auto"
        Height="Auto"
        Margin="0,20,0,0"
        HorizontalAlignment="Center"
        VerticalAlignment="Top"
        HorizontalContentAlignment="Center"
        VerticalContentAlignment="Center"
        AlternatingRowBackground="WhiteSmoke"
        AlternationCount="2"
        AutoGenerateColumns="True"
        BorderBrush="Black"
        BorderThickness="1"
        CanUserAddRows="False"
        CanUserResizeRows="False"
        CanUserSortColumns="False"
        ColumnHeaderHeight="35"
        EnableColumnVirtualization="True"
        EnableRowVirtualization="True"
        HorizontalScrollBarVisibility="Hidden"
        ItemsSource="{Binding Path=ObjectMessageDataTable.DefaultView, IsAsync=True, UpdateSourceTrigger=PropertyChanged}"
        RowHeight="30"
        VerticalScrollBarVisibility="Hidden" />

Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!