4

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

Student
  • 317
  • 1
  • 8
  • 16
  • The fields aren't part of the visual or logical trees so the bindings will fail. You can find a workaround to this here: http://blogs.infragistics.com/blogs/josh_smith/archive/2008/06/06/binding-a-xamdatagrid-field-property.aspx – alhalama Feb 07 '12 at 00:50

4 Answers4

4

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>
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
larsmoa
  • 12,604
  • 8
  • 62
  • 85
3

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>
dugas
  • 12,025
  • 3
  • 45
  • 51
1

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

user500099
  • 964
  • 9
  • 9
-1

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

Noich
  • 14,631
  • 15
  • 62
  • 90