Hi guys,
I have another problem using the XamComboEditor for WPF (v13.1) used in a MVVM project.ItemsSource of the XamComboEditor is bound to an IList of enum values. In the editor the values are not displayed as they are but modified by converters to display a name and an icon, depending on the selected enum value. Using a template I can modify the dropdown area of the combo editor to show the items as described above. But unfortunately this works for the items displayed in the dropdown area only. If I select an item and the combo editor lost the focus, the item in den (collapsed) combo editor switches to the enum value and does not keep it´s "style" displayed in the dropdown. I guess my template works for the dropdown section only but not for the "text box" part of the XamComboEditor. Is there a way to apply a template to the "text box" part of the combo editor as well?It is currently not possible to change the view model, so I´m looking for a solution that works with the existing view model.
Here is the code I´m using for the XamComboEditor:
<igEditors:XamComboEditor Margin="0 2 10 4" Grid.Row="2" Grid.Column="1" ItemsSource="{Binding Path=TypeFilters}" Value="{Binding Path=SelectedTypeFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEditable="False" DropDownResizeMode="None"> <igEditors:XamComboEditor.ComboBoxStyle> <Style TargetType="ComboBox"> <Setter Property="ItemTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <Image Source="{Binding Path=., Converter={StaticResource dataTypeToIconConverter}}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 2 4 2" Width="16" Height="16"/> <TextBlock Text="{Binding Path=., Converter={StaticResource dataTypeToStringConverter}}" /> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style> </igEditors:XamComboEditor.ComboBoxStyle> </igEditors:XamComboEditor>
I hope this makes my problem clear. I´m still pretty new to the whole thing ;)
Daniel
additional:
I can use the ValueToDisplayTextConverter property to control how the selected text(!) will be displayed using something like
ValueToDisplayTextConverter="{StaticResource dataTypeToStringConverter}
Is there a chance to control not only a text representation of the selected item but also a combination of text and an icon like it is done with the template for the ComboBoxStyle (see above).
I´m getting more and more confused using this XamComboEditor... :´-(
Hello Daniel,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I created a Style for the XamComboEditor and set its Template to be similar to the ComboBox’ ItemTemplate, but with a different Bindings since the DataContext there is different. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.