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
360
XamComboEditor: how to set template for selected item?
posted

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