1

I'm using a RadGridView (Telerik). I'm trying to make a column editable only for certain rows, but what I'm trying doesn't seem to be working and I'm not sure how to do it.

My grid is this:

<telerik:RadGridView HorizontalAlignment="Left" Margin="12,12,12,12" Name="radGridView1" VerticalAlignment="Top" ItemsSource="{Binding FeedList}" ShowGroupPanel="False" AutoGenerateColumns="False" ShowInsertRow="True" EditTriggers="Default">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Feed" DataMemberBinding="{Binding Path=Name}" Width="150" IsReadOnly="{Binding Path=ReadOnly}" />
        <telerik:GridViewDataColumn Header="Url" DataMemberBinding="{Binding Path=Url}" Width="*"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

The bound object has a property, but the Path for the IsReadOnly binding is relative to the DataContext for the form and not the bound object. How would I make it relative to the bound object in this case?

Pete
  • 6,585
  • 5
  • 43
  • 69

2 Answers2

0

In case anyone comes across this on a search. The answer is the GridView's datacontext is bound to the collection it's displaying and doesn't have access to the Window or UserControl's datacontext.

Thomas Levesque has a blog entry on the subject. He puts together a BindingProxy class that you can use to pass in the datacontext to the radgridview.

http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-data-when-the-datacontext-is-not-inherited/

Jason Massey
  • 1,088
  • 10
  • 18
-1

Intellisense must have been messed up. Somehow missed the IsReadOnlyBinding property of GridViewDataColumn, which does exactly what I want. Not sure why IsReadOnly couldn't do it, though.

Pete
  • 6,585
  • 5
  • 43
  • 69