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
700
Adding Image/Adorner to all editable cells
posted

Hey,

we want to add a image to all editable cells so the user can see which cells he can edit. It should looks like when implementing IDataErrorInfo but only for cells which are editable (AllowEdit = true).

We have already tried a style for the CellValuePresenter:

 <Style x:Key="BaseCellValuePresenterStyle" TargetType="{x:Type igDP:CellValuePresenter}">
   
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Field.Settings.AllowEdit}" Value="True">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                            <Grid Background="{TemplateBinding Background}" >
                                <Image Source="../Images/edit.png" HorizontalAlignment="Left"/>
                                <ContentControl  Content="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Value}"/>
                            </Grid>                         
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </Style.Triggers>

    </Style>

But with this style our custom controls in the cells are no displayed. Can we achive this behavior with a simple style or we need a adorner control or something?

Best regards

Lukas

Parents
  • 34810
    Verified Answer
    Offline posted

    Hello Lukas,

    I have been investigating into your requirement, and I would highly recommend against doing things the way you are currently doing them, as re-templating the CellValuePresenter element entirely will strip the original template, and you will effectively not be able to edit any of your cells this way.

    Instead, I would recommend inclusion of the default template for CellValuePresenter and modifying that. This can be found within the DataPresenterGeneric_Express.xaml file commonly found at the following directory with Infragistics controls installed:

    C:\Program Files (x86)\Infragistics\2019.1\WPF\DefaultStyles\DataPresenter\

    You can then make modifications to this template, and I would expect that if you add your Image as the first child of the CardPanel element that makes up the parent element of the ControlTemplate, you should be able to see your Image in the grid cells. You can then give the CellValuePresenter style an x:Key and apply it to your Fields that have AllowEdit set to true by setting it to the CellValuePresenterStyle of that Field via a StaticResource.

    I am attaching a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    7230.XDGCheckEditorRetemplateDemo.zip

Reply Children
No Data