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
90
XamComboEditor ItemTemplate for both dropdown and selected value
posted

This post started of with the intention of asking how to get an XamComboEditor to use the same template for both the items in the list and the selected value. When i encountered the problem i spent an awful lot of time reading through posts that didn't have a clear answer to the question. So insted i'd like to post my solution and ask if any one can provide any pointers to change it to the best practice way of doing things.

 

<igEditors:XamComboEditor HorizontalAlignment="Left" Margin="43,108,0,0" Name="xamComboEditor1" VerticalAlignment="Top" Width="192" ItemsSource="{Binding Source={StaticResource StaffViewSource}}">
            <igEditors:XamComboEditor.ComboBoxStyle>
                <Style TargetType="ComboBox">
                    <Setter Property="ItemTemplate">
                        <Setter.Value>
                                <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Label Content="{Binding Path='sStaffCode'}"/>
                                    <Label Content="{Binding Path='Entity.Person.sFirstName'}"/>
                                    <Label Content="{Binding Path='Entity.Person.sLastName'}"/>
                                </StackPanel>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </igEditors:XamComboEditor.ComboBoxStyle>
            <igEditors:XamComboEditor.Style>
                <Style TargetType="igEditors:XamComboEditor">
                    <Setter Property="Selector.ItemTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <StackPanel>
                                    <Label Content="{Binding Path='sStaffCode'}"/>
                                    <Label Content="{Binding Path='Entity.Person.sFirstName'}"/>
                                    <Label Content="{Binding Path='Entity.Person.sLastName'}"/>
                                </StackPanel>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </igEditors:XamComboEditor.Style>
        </igEditors:XamComboEditor>