WPF ComboBox

This is dedicated content to the ComboBox in WPF.  In this we learn how to use the ComboBox and the many essential properties it has. We cover creating items in our XAML, Binding the ItemSource property, Creating item templates and also playing with the container styles. This, unlike other control episodes, is covered in great detail and below will be provided code if you wish to follow along. Please comment if you have any questions.

 

Code From Episode:

ComboBoxViewModel.cs

    public class ComboBoxViewModel
    {
        public List<string> NameCollection { get; set; }
        public List<Brush> BrushCollection { get; set; }

        public ComboBoxViewModel()
        {
            NameCollection = new List<string>()
            {
                "Joe",
                "Jane",
                "Jerry",
                "Mary",
                "Larry"
            };

            BrushCollection = new List<Brush>()
            {
                Brushes.Red,
                Brushes.Green,
                Brushes.Blue,
                Brushes.Orange
            };
        }
    }

YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *