Binding GridViewColumn IsReadOnly Field

Feb 10, 2009 at 12:42 AM
I am attempting to set the readonly value on a column according to whether or not a value is empty or null.
I am using a data grid that binds to an observable list.  All the value are shown accordingly, but when I try to bind the IsReadOnly value, I never get the value I want.  Here are my binding properties:

        public Boolean Selected { get; set; }
        public string Status { get; set; }
        public string ObjectiveNumber { get; set; }
        public string Req { get; set; }
        public string Description { get; set; }
        public string VerifData { get; set; }
        public string ExpectedResult { get; set; }
        public string Stat { get; set; }
        public string Preview { get; set; }

I added this property to test, and set it to true:
        public Boolean ReadOnly { get; set; }

Here is my grid:
        <toolkit:DataGrid ItemsSource="{Binding Source={StaticResource objectives}}" AutoGenerateColumns="False" SelectionChanged="SelectedRow" SelectionMode="Single" Margin="0,0,0,0" CanUserResizeColumns="False" CanUserDeleteRows="False" CanUserResizeRows="False">
            <toolkit:DataGrid.Columns >
                <toolkit:DataGridCheckBoxColumn Binding="{Binding Path=Selected}" IsReadOnly="{Binding Path=ExpectedResult, Converter={StaticResource StrConverter}}" />
                <toolkit:DataGridTextColumn Header="Expected Result" Binding="{Binding Path=ExpectedResult}" CanUserSort="False" IsReadOnly="True" ElementStyle="{StaticResource columnStyle}" MaxWidth="500" />
            </toolkit:DataGrid.Columns>
        </toolkit:DataGrid>


Here is my other attempt using binding to a property
        <toolkit:DataGrid ItemsSource="{Binding Source={StaticResource objectives}}" AutoGenerateColumns="False" SelectionChanged="SelectedRow" SelectionMode="Single" Margin="0,0,0,0" CanUserResizeColumns="False" CanUserDeleteRows="False" CanUserResizeRows="False">
            <toolkit:DataGrid.Columns >
                <toolkit:DataGridCheckBoxColumn Binding="{Binding Path=Selected}" IsReadOnly="{Binding Path=ReadOnly}" />
                <toolkit:DataGridTextColumn Header="Expected Result" Binding="{Binding Path=ExpectedResult}" CanUserSort="False" IsReadOnly="True" ElementStyle="{StaticResource columnStyle}" MaxWidth="500" />
            </toolkit:DataGrid.Columns>
        </toolkit:DataGrid>


And here is the converter!
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return string.IsNullOrEmpty((string)value);
        }


FYI - I deleted some of the columns just to save screen width.
Anywho none of these seem to work, but setting it to a value of IsReadOnly (true/false) seem to work.  An ideas would be apprieciated!