menu

WinUI

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ComboBoxTokenItem - API Reference

    Show / Hide Table of Contents

    Class ComboBoxTokenItem

    Represents the container for the items that are generated in the selection area of SfComboBox control in multiple selection token mode.

    Inheritance
    System.Object
    TokenItem
    ComboBoxTokenItem
    Inherited Members
    TokenItem.OnCreateAutomationPeer()
    TokenItem.OnApplyTemplate()
    TokenItem.OnPreviewKeyDown(KeyRoutedEventArgs)
    TokenItem.OnTapped(TappedRoutedEventArgs)
    Namespace: Syncfusion.UI.Xaml.Editors
    Assembly: Syncfusion.Editors.WinUI.dll
    Syntax
    public class ComboBoxTokenItem : TokenItem
    Examples

    The following example shows how to customize the style of ComboBoxTokenItem generated in the selection area of ComboBox control.

    • XAML
    • C#
    <Grid>
        <Grid.DataContext>
            <local:ComboBoxViewModel/>
        </Grid.DataContext>
        <editors:SfComboBox SelectionMode="Multiple"
                            MultiSelectionDisplayMode="Token"
                            ItemsSource="{Binding Sports}"
                            TextMemberPath="Name"
                            DisplayMemberPath="Name">
              <editors:SfComboBox.TokenItemStyle>
                   <Style TargetType = "editors:ComboBoxTokenItem" >
                       <Setter Property="Foreground" Value="Red"/>
                       <Setter Property = "Background" Value="LightCyan"/>
                   </Style>
              </editors:SfComboBox.TokenItemStyle>
        </editors:SfComboBox>
    </Grid>
    public class Sport
    {
        public string Name { get; set; }
        public int ID { get; set; }
    }
    
    public class ComboBoxViewModel
    {
        public ObservableCollection<Sport> Sports { get; set; }
        public ComboBoxViewModel()
        {
            Sports = new ObservableCollection<Sport>();
            Sports.Add(new Sport() { Name = "Cricket", ID = 0 });
            Sports.Add(new Sport() { Name = "Football", ID = 1 });
            Sports.Add(new Sport() { Name = "Golf", ID = 2 });
            Sports.Add(new Sport() { Name = "Hockey", ID = 3 });
        }
    }

    Constructors

    ComboBoxTokenItem()

    Initializes a new instance of the ComboBoxTokenItem class.

    Declaration
    public ComboBoxTokenItem()

    See Also

    TokenItemStyleSelector
    TokenItemTemplate
    TokenItemTemplateSelector
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved