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.
Thanks Stefan,
this is pretty much the same I came up with after hours of trying... and it does not work.It works as long as you keep the combo focused but if the combo has lost the focus it just displays a part of the selected item and not all information of the selected item.
Maybe this image describes my problem:
1. screenshot:- combo is open (dropdown visible), no item selected. All items are shown as expected, both properties of the item (number and text) are shown.2. screenshot:- item "1 AB" selected. Item is shown as expected. Combo has still focus. Both properties of the item (number and text) are shown.
3. screenshot:- item "1 AB" still selected, but combo does not have the focus. Item is not shown as expected, only one property of the object (the text "AB") is shown.
I guess the problem is caused by different behavior of the controls the XamComboEditor is composed of. It works fine for the "dropdown part" whichobviously is derived from Microsofts ComboBox but it does not work for the "textbox part" of the XamComboEditor.I have no idea how to solve this. And - sorry - I don´t think that this is possible with that control at all.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Hi Stefan,
like many times before I have currently no time to work on this issue. Hope that I can continue with this in a week or so.
Sorry...
I will look forward for your reply.