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
1470
ComboEditor with ItemTemplates
posted

Hi there

I try to use xamComboEditor to "translate" a string value in a property to an image with a description. The object which contains this property is in a collection, which is bound to a xamDataGrid. I'm able to achieve the wanted behavior, when the xamComboEditor is in edit mode and/or the list is dropeddown.

But how to show the DataTemplate, when the xamComboEditor is collapsed and/or not in edit mode?

In the sample browser, the wanted behavior can be achived, when the property 'IsEditable' is set to false. But this does not work for me here, also i need to have the properties 'DisplayMemberPath' and 'ValueMemberPath' set correctly, so the xamComboEditor works correctly in the xamDataGrid context and bound to a property containing a System.String and not an object of the values in the xamComboEditor ItemsSource.

I created a simplified test project, which shows my problem at runtime. Any tipps how to achieve this? In the sample, there is an "Orchestrator" which is the DataContext. This orchestrator does implement two properties:

Items --> The data

ValueDescriptions --> The translation of Item.Type to the Image and Description

Regards

xamDataGrid_DropDownWithImages.zip

Parents Reply
  • 29065
    Offline posted in reply to Andreas Gorog

    Hello, 

    I still recommend reviewing the topic above, and to answer your question, in order to change what you see in the cells when not in edit mode you will have to use a Display Template and the simplest way to do that is using a TemplateField rather than a basic Field type as seen in your sample. Inside the Display Template you can put a TextBlock and in the EditTemplate you'll have to add your Combo, because as it is currently, if you keep your editor style the DisplayTemplate won't work because the EditorStyle is overriding the field. So you'll have to remove this code for the Display Template to work:

    eg.

    <igDP:FieldLayout.Fields>
    
                            <igDP:TemplateField Name="Type" >
                              
                                <!--<igDP:TemplateField.Settings>
                                    <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" EditorStyle="{StaticResource editorStyle}"/>
                                </igDP:TemplateField.Settings>-->
    
                                <igDP:TemplateField.DisplayTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="Test"
                       HorizontalAlignment="Right"/>
                                    </DataTemplate>
                                </igDP:TemplateField.DisplayTemplate>
                            </igDP:TemplateField>
    
    
    </igDP:FieldLayout.Fields>

Children