DataGrid.IsReadOnly Property

Gets or sets a value that indicates whether the user can edit the values in the control.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

public bool IsReadOnly { get; set; }
<sdk:DataGrid IsReadOnly="bool"/>

Property Value

Type: System.Boolean
true if the control is read-only; otherwise, false. The default is false.


When setting this property to true while the control is in editing mode, the edit cannot be committed or reverted.

Dependency property identifier field: IsReadOnlyProperty

If the IsReadOnly property is set to true, none of the cells can enter editing mode.

You can set this behavior for individual columns by setting the DataGridColumn.IsReadOnly property. If the DataGridColumn.IsReadOnly property and the DataGrid.IsReadOnly property are both set, a value of true will take precedence over a value of false.

The following code example demonstrates how to set the IsReadOnly property in code. This example is part of a larger example available in the Walkthrough: Customizing the DataGrid Control Using Properties topic.

private void cbReadOnly_Changed(object sender, RoutedEventArgs e)
    CheckBox cb = sender as CheckBox;
    if (this.dataGrid1 != null)
        this.dataGrid1.IsReadOnly = (bool)cb.IsChecked;


Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions