i using the xamDataGrid. i want to create dynamic cell editor... for example, when i click cell #2, if the value of the cell #1 is 3, i want to display the editor for date and time, and if the value of the cell #1 is 4, i want to display the editor for custom data.
Hi,
I think the following technique should satisfy your requirement...
<Window.Resources> <Style x:Key="VariableCellEditorStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Cells[SomeField].Value}" Value="0"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBox Background="LightBlue" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" /> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> <DataTrigger Binding="{Binding Path=Cells[SomeField].Value}" Value="1"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <igEditors:XamTextEditor Background="Gray" IsReadOnly="True" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" /> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style></Window.Resources><igDP:XamDataGrid x:Name="xamDG"> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="State"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource VariableCellEditorStyle}" /> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts></igDP:XamDataGrid>
Josh
thank you for your advice