This question is locked. New answers and comments are not allowed.
I am trying to set columns to IsReadOnly=true. Yet am finding that setting the value often leaves the rows editable. I can change the values in the first two rows despite "UserCanOnlyRead" being equal to true. Am I doing something wrong? None of the rows in this test project should be editable, right?
This is the code behind:
<UserControl.Resources> <DataTemplate x:Key="myTemplate"> <RadioButton IsChecked="{Binding Allow, Mode=TwoWay}" /> </DataTemplate></UserControl.Resources><Grid x:Name="LayoutRoot"> <telerik:RadGridView ItemsSource="{Binding ElementName=LayoutRoot, Path=Parent.TestData}"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Allow}" IsReadOnlyBinding="{Binding ElementName=LayoutRoot, Path=Parent.UserCanOnlyRead}"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Allow}" CellTemplate="{Binding Source={StaticResource myTemplate}}" IsReadOnly="True"/> <telerik:GridViewDataColumn DataMemberBinding="{Binding Allow}" IsReadOnly="True"/> </telerik:RadGridView.Columns> </telerik:RadGridView></Grid>This is the code behind:
public partial class RadGridViewDisableColumn : Page{ public bool UserCanOnlyRead = true; List<TestType> _testData; public List<TestType> TestData { get { if (_testData == null) { _testData = new List<TestType>(); for (int i = 0; i < 10; i++) { _testData.Add(new TestType() { Allow = i % 4 == 0 }); } } return _testData; } } public RadGridViewDisableColumn() { InitializeComponent(); } public class TestType { public bool Allow { get; set; } }}