How to make one column editable in a readonly datagrid?

后端 未结 1 1138
误落风尘
误落风尘 2021-02-08 09:30

How to make one column editable in a readonly datagrid?



        
1条回答
  •  渐次进展
    2021-02-08 10:34

    I created a sample where I bound the ItemsSource of the DataGrid to an ObservableCollection and from here you have two options.

    1. Set AutoGenerateColumns="False" on the DataGrid and set IsReadOnly="True" for all columns except the column you want to be editable you will set IsReadOnly="False".
    2. AutoGenerateColumns="True" (it is the default, so you could just remove the attribute from the XAML) and make the setters private in your ViewModel for all of the properties except the column you want to be editable.

    Here is my sample code for option 1:

    
        
            
            
            
            
            
            
        
    
    

    0 讨论(0)
提交回复
热议问题