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
Hello Andreas,
Thank you for contacting Infragistics. Please try clarifying your requirements and the issue(s) you are running into. Note, if all your looking to do is template the columns cells when not in edit mode then you can use a DisplayTemplate and also an EditTemplate.
eg.
https://www.infragistics.co.kr/help/wpf/xamdatagrid-configuring-template-field
Thank you for your reply. But i think the requirements and issues are pretty clear?Please download the attached sample and have a detailed look. I really don't know how to explain further..
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:
<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>
Thank you for your answer, but this scenario is not the same as mine...I need the data of the according object in ValueDescriptions to display the UI correctly. And if i'm doing it with the TemplateField, i'm missing all the data i need to display the UI correctly.My provided sample is rather simple, and if you're able to achieve the wanted behavior (without changing anything in the underlying model) i'm more than happy to go your way.So i'll try to simplify it even more:I got data object:Item
this has a property "Value"
which is type
System.String.
And on the other side, i got a list of (describing-)objects, which describing the value of the data object.
It has two properties:"Type" (matching "Value" of the data-object) System.String"Description" (the description which should get showed to the user, in display and edit mode) System.StringSo the ComboBoxEditor is selecting the correct describing-object. This object contains a description which has to be shown (and a value which i use to display the correct image, but this could also come from the data-object, then it's the same and which get matched by the ComboBoxEditor).
Do you understand my scenario now?
I attached a modified version of your sample demonstrating how to use a TemplateField with Display/EditTemplates together with your EditorStyle.
xamDataGrid_DropDownWithImages (Templates).zip
Hi
As i wrote before, the underlying model can not be changed in my scenario! I need to have the 'Type' property to be of 'System.String' and you changed it to the "ValueDescription". Like this it also would be easy for me.Also, i does not show the dropdown button, and when i initially click into the grid cell, it shows me an ampty ComboBoxEditor. Can you please escalate this issue? Thanks.And just to make it clear, i do not need a different view on edit/display. I need the same..Also to get back to my initial question, why does the XamComboEditor behave differently used in a XamDataGrid context? In the sample 'xamComboEditor/Display/Using DataTemplates in ComboEditor' when the property 'IsEditable' is set to false, it behaves exactly how i want it.
I would like you to take a look at the sample project I am attaching. This is a modification of your original sample project where the underlying model is not changed, but the ControlTemplate of the XamComboEditor is brought in and modified to include your ItemTemplate in the structure, as this would be the simplest way to achieve what you are asking for without changing the structure of the model. Just for reference, this ControlTemplate can be found in the EditorsGeneric.xaml file commonly found at the following directory with Infragistics controls installed:
C:\Program Files (x86)\Infragistics\<version>\WPF\DefaultStyles\Editors
The reason your ItemTemplate is not showing through in this case is because you are currently writing the ItemTemplate on the underlying Microsoft ComboBox by targeting the ComboBoxStyle => ItemTemplate property in this case. This ComboBox is only used by the XamComboEditor when in edit mode and so the XamComboEditor shows its EditTemplate. When you exit edit mode on the cell, the normal ControlTemplate comes back into view in the case of usage within a XamDataGrid, and the ComboBox does not exist in the ControlTemplate.
Regarding the sample XamComboEditor => Display => Using Data Templates in our samples browser, this is our “other” XamComboEditor. There are two XamComboEditors in the Infragistics for WPF toolset, and the one you are using is the Infragistics.Windows.Editors.XamComboEditor, which was designed to be an editor for the XamDataGrid. The other one that is shown in the sample referenced, is the Infragistics.Controls.Editors.XamComboEditor originally designed for Silverlight, and it is more meant to be our standalone combo editor.
The sample project demonstrating your requirement is attached. I hope this helps.
Please let me know if you have any other questions or concerns on this matter.
8546.xamDataGrid_DropDownWithImages.zip
I've implemented this solution, but am getting an error message for each combo box item. The error message is "System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ComboBoxItem:'ComboBoxItem' (Name='')". I verified the error is present in the 8546.xamDataGrid_DropDownWithImages.zip project. I can't figure out to correct this. Any suggestions?
Hi thereI finally had time to look at your solution, implement and test it. And this works as expected, thank you very much for your sample and detailed explanation! Perfect. Have a good week!Regards