Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
325
Binding enabled/allowedit property
posted

 

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>

Parents
No Data
Reply
  • 2180
    Offline posted

    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

Children