ComboBoxItemAdv
It can be added inside the ComboBoxAdv control. It is originally derived from the ComboBoxItem.
Sample link
To view samples:
- Run samples from installed location.
Example: C:\Program Files (x86)\Syncfusion\Essential Studio\XX.X.X.XX\Samples - Now move to WPF folder in which WPF samples has been present.
- Choose ComboBox from Tools.WPF to run ComboBoxAdv demo.
Adding items using DataBinding
You can use the DisplayMemberPath
property to set the value for items that needs to be displayed in the drop-down list.The below code snippet will be used to bind the DataSource to the ComboBoxAdv.
<syncfusion:ComboBoxAdv Name="comboBoxAdv" ItemsSource="{Binding Products}" DisplayMemberPath="Name" SelectedValue="{Binding SelectedItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
public class Model
{
public string Name { get; set; }
}
public class ViewModel : INotifyPropertyChanged
{
private string selectedItems;
public string SelectedItems
{
get
{
return selectedItems;
}
set
{
selectedItems = value;
RaisePropertyChanged("SelectedItems");
}
}
private ObservableCollection<Model> products;
public ObservableCollection<Model> Products
{
get
{
return products;
}
set
{
products = value;
RaisePropertyChanged("Products");
}
}
public ViewModel()
{
Products = new ObservableCollection<Model1>();
Products.Add(new Model() { Name = "UK" });
Products.Add(new Model() { Name = "CA " });
Products.Add(new Model() { Name = "DE" });
Products.Add(new Model() { Name = "IN" });
Products.Add(new Model() { Name = "UA" });
}
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
var property = PropertyChanged;
if (property != null)
property(this, new PropertyChangedEventArgs(propertyName));
}
}
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page