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
375
Alternating background style for the XamComboEditor
posted

How can I create a style for the XamComboEditor so it has alternating backbround like the XamDataGrid?

Parents
No Data
Reply
  • 54937
    Suggested Answer
    Offline posted

    Another option if you are using .net 3.5 sp1 or later is to provide a custom style for the contained ComboBox and set its AlternationCount and use the AlternationIndex on the comboboxitem's style. e.g.

    <igEditors:XamComboEditor>
        <igEditors:XamComboEditor.ComboBoxStyle>
            <Style TargetType="ComboBox">
                <Style.Resources>
                    <AlternationConverter x:Key="BackgroundConverter">
                        <SolidColorBrush Color="Blue" />
                        <SolidColorBrush Color="Red" />
                    </AlternationConverter>
     
                    <Style TargetType="ComboBoxItem" x:Key="alternatingItem">
                        <Setter Property="Background" 
                            Value="{Binding RelativeSource={RelativeSource Self},
                            Path=(ItemsControl.AlternationIndex),
                            Converter={StaticResource BackgroundConverter}}"/>
                    </Style>
                </Style.Resources>
                
                <Setter Property="ItemContainerStyle" Value="{StaticResource alternatingItem}" />
                <Setter Property="AlternationCount" Value="2" />
            </Style>
        </igEditors:XamComboEditor.ComboBoxStyle>
        
        <igEditors:XamComboEditor.ItemsProvider>
            <igEditors:ComboBoxItemsProvider>
                <sys:String>ABC</sys:String>
                <sys:String>DEF</sys:String>
                <sys:String>GHI</sys:String>
                <sys:String>JKL</sys:String>
            </igEditors:ComboBoxItemsProvider>
        </igEditors:XamComboEditor.ItemsProvider>
    </igEditors:XamComboEditor>

     

Children