I am trying to convert my very simple wpf datagrid to the infragistics datagrid. I am not sure how to disable a specific cell based a property. I'm now using a textbox as datatemplate instead of a normal datagridtextcolumn. How can I create a similar infragistics grid (without code behind)?
The way my datagrid is setup:
<DataGrid ItemsSource="{Binding Path=MyDtos}" >
<DataGrid.Columns>
<DataGridTemplateColumn Header="Weight">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=Weight, Mode=TwoWay, StringFormat=F1}" IsEnabled="{Binding Path=AllowEdit}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Path=AllowEdit, Mode=TwoWay}" Header="AllowEdit" />
</DataGrid.Columns>
</DataGrid>
Hi,
Here is a sample code:
<igDP:XamDataGrid x:Name="xamDataGrid">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:Field Name="Weight">
<igDP:Field.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="igEditors:XamNumericEditor">
<Setter Property="IsEnabled" Value="{Binding Path=DataItem.AllowEdit, Mode=OneWay}"></Setter>
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
I suppose that Weight is a numeric type, but if it is not you can change the TargetType to any other editor. Let me know if this isn’t what you need.
Thanks,
Diyan Dimitrov
I would also like to bind AllowDelete on AllowEdit and tried the following but it doesn't work, any ideas?:
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AllowDelete="{Binding Path=ActiveDataItem.AllowEdit, Mode=OneWay}"/>
</igDP:XamDataGrid.FieldLayoutSettings>
Femke
Hi Diyan,
This is perfect! Many thanks!!