DataGrid.EnableRowVirtualization is not available in UWP

Dennis Arriola 61 Reputation points
2021-06-10T09:27:26.513+00:00

Why is DataGrid.EnableRowVirtualization is not available in UWP?104222-image.png

I need this so that DataGrid wont instantiate a DataGridRow object for each data item in the bound data source.

This is the best solution to fix auto checking of checkboxes in a DataGrid when user scrolls down and up.
Unfortunately, this is not available in UWP. Is there a work around to fix auto checking of checkboxes in DataGrid when user scrolls up and down?

Thanks~

Universal Windows Platform (UWP)
0 comments No comments
{count} vote

Accepted answer
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,866 Reputation points
    2021-06-11T01:57:07.897+00:00

    Hello, Welcome to Micorosoft Q&A,

    DataGrid.EnableRowVirtualization is not available in UWP

    EnableRowVirtualization, please refer document, it is desktop top DataGrid property, it is not apply to UWP DataGrid. And UWP DataGrid is enable virtualization automatically. If you want to disable checkbox auto overwrite, please binding it with specific bool property.

    <controls:DataGridTemplateColumn Header="Serach" Visibility="Collapsed">  
        <controls:DataGridTemplateColumn.CellTemplate>  
            <DataTemplate>  
                <StackPanel Orientation="Horizontal">  
                    <CheckBox Content="{Binding Name}" IsChecked="{Binding Complete}" />  
                </StackPanel>  
            </DataTemplate>  
        </controls:DataGridTemplateColumn.CellTemplate>  
    </controls:DataGridTemplateColumn>  
    

    Model Class

    public class Item :INotifyPropertyChanged   
    {  
        public string Name { get; set; }  
        public bool IsSearch { set; get; }  
        private bool _complete;  
        public bool Complete  
        {  
            get  
            {  
                return _complete;  
            }  
            set  
            {  
                _complete = value;  
                OnPropertyChanged();  
            }  
        }  
          
      
        public event PropertyChangedEventHandler PropertyChanged;  
        private void OnPropertyChanged([CallerMemberName] string propertyName = null)  
        {  
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));  
        }  
    }  
    

    If you do want to disable virtualization, you may try to place DataGrid in the ScrollViewer, please note disable virtualization will consume more memory and degrade performance.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.