4
votes

In my XAML I'm trying to bind AllowEdit of my XamDataGrid to a property

<igDP:XamDataGrid.FieldSettings>
  <igDP:FieldSettings AllowEdit="{Binding Path=DataItem.Approved}"/>
</igDP:XamDataGrid.FieldSettings>

But it doesn't work. All other bindings work fine. Any ideas? I'm new to WPF so any help would be appreciated

4
The fields aren't part of the visual or logical trees so the bindings will fail. You can find a workaround to this here: blogs.infragistics.com/blogs/josh_smith/archive/2008/06/06/… - alhalama

4 Answers

4
votes

I use a style to get around this limitation, e.g.:

<igWPF:Field Name="SomeValue">
    <igWPF:Field.Settings>
    <igWPF:FieldSettings EditorType="{x:Type igWPF:XamNumericEditor}">
        <igWPF:FieldSettings.EditorStyle>
        <Style TargetType="{x:Type igWPF:XamNumericEditor}">
            <Setter Property="IsReadOnly" Value="{Binding DataItem.IsReadOnly}" />
        </Style>
        </igWPF:FieldSettings.EditorStyle>
    </igWPF:FieldSettings>
    </igWPF:Field.Settings>
</igWPF:Field>
3
votes

I usually used a style to achieve this as in @larsmona's answer above. Recently I learned about using CellBindings and FieldBindings to achieve this.

https://www.infragistics.com/community/blogs/b/blagunas/posts/feature-spotlight-new-fetaures-in-the-infragistics-wpf-xamdatagrid

https://www.infragistics.com/help/wpf/xamdatagrid-binding-cell-settings-data-item-properties

http://help.infragistics.com/Help/Doc/WPF/2014.2/CLR4.0/html/xamDataPresenter_Binding_Cell_Settings_Data_Item_Properties.html

<igDP:Field Name="SomeName" Row="0" Column="1" Label="SomeLabel" AllowEdit="True">
  <igDP:Field.CellBindings>
   <igDP:CellBinding Target="Editor" Property="IsReadOnly" Binding="{Binding DataItem.SomeProperty}"></igDP:CellBinding>
  </igDP:Field.CellBindings>
</igDP:Field>
1
votes

Apparently you (still.....) cannot bind this property: http://www.infragistics.com/community/forums/t/10907.aspx sigh...

-1
votes

Perhaps you're binding to ObservableCollection? If that's the case, you can't edit your items. You can try bind to BindingList instead.