Hello,
I'm trying to create a column in the XamDataGrid that shows an enumeration value. This enumeration value is displayed as a symbol instead of plain text. Users can click the column and edit the value, in which case they will see a dropdownlist with all enumeration values displayed as symbols. The following snippet is part of my code:
<igDP:Field Name="Status" Label="State" Width="40">
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" EditAsType="{x:Type model:MyEnumeration}">
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="igDP:CellValuePresenter">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<ContentPresenter Content="{TemplateBinding Value}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsProvider">
<igEditors:ComboBoxItemsProvider ItemsSource="{Binding Source={StaticResource MyEnumerationValuesProvider}}" />
<Setter Property="DropDownButtonDisplayMode" Value="OnlyInEditMode" />
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
MyEnumeration is the enumeration of course. MyEnumerationValuesProvider is an ObjectDataProvider that returns all enumeration values. I also have a data template set to the enumeration type, but for some reason this data template is not applied to the column. It is applied correctly when entering edit mode however. So, to correct this I added the CellValuePresenterStyle as you can see, but now I cannot edit or even select the cell anymore. Even when I set the following properties on the FieldSettings, I still cannot select or edit the column values:
AllowEdit="True" CellClickAction="SelectCell" LabelClickAction="SelectField"
Any advice is appreciated!
Thank you for your post. I have been looking into your issue and by defining your own template for the CellValuePresenter you are deleting the default one that contains the editor( in your case the XamComboEditor). Instead of re-templating the CellValuePresenter, you can re-template the ‘ComboEditor_NonEditableComboBoxTemplate’ of the ComboBox which is in part of the XamComboEditor. You can find the default style for it in :
C:\Program Files (x86)\Infragistics\NetAdvantage 2012.2\WPF\DefaultStyles\Editors\EditorGeneric.xaml
Let me know, if you need any further assistance on this matter.
Hello Yanko,
Thank you for your time. Unfortunately I was not successful trying to do this. I added the template but the grid seems to ignore it. Even when I comment out all the content everything is just like it was. I have added my solution as attachment. Could you please take a look at it?
I found the answer myself. I should have used a ContentTemplate instead of the Template. In that ContentTemplate a simple ContentPresenter is enough, because now my data template is being respected.
<Setter Property="ContentTemplate">
<DataTemplate>
<ContentPresenter Content="{Binding Value}" />
</DataTemplate>
Hi Sard,
Thank you for your feedback. I am glad that you have managed to solve your issue.