Hello All,

I want to create a combobox of Countries with 3 Group Headers as "Favourites", "Frequently Used" and "Rest of the world".
I am not sure how to achieve the favourites and frequently used functionality.
I have written some sample code that runs fine but the real functionality for favourites and frequently used is missing.
Please help me on this and kindly update on how to achieve the same.
My sample code is as follows :-

 <ComboBox x:Name="cmbCountry" DisplayMemberPath="Item" Height="25" Width="200" HorizontalAlignment="Center" VerticalAlignment="Center">
            <ComboBox.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="12"/>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ComboBox.GroupStyle>
        </ComboBox>

And....

public partial class CountryUC : UserControl
    {
        public CountryUC()
        {
            InitializeComponent();
            DataContext = this;

            List<CategoryItem<string>> items = new List<CategoryItem<string>>();

            items.Add(new CategoryItem<string> { Category = "----- Favourites -----", Item = "India" });
            items.Add(new CategoryItem<string> { Category = "----- Favourites -----", Item = "Germany" });
            items.Add(new CategoryItem<string> { Category = "----- Frequently Used -----", Item = "United States" });
            items.Add(new CategoryItem<string> { Category = "----- Frequently Used -----", Item = "United Kingdom" });
            items.Add(new CategoryItem<string> { Category = "----- Rest of the world -----", Item = "Australia" });
            items.Add(new CategoryItem<string> { Category = "----- Rest of the world -----", Item = "Canada" });

            //Need the list to be ordered by the category or you might get repeating categories
            ListCollectionView lcv = new ListCollectionView(items.OrderBy(w => w.Category).ToList());

            //Create a group description
            lcv.GroupDescriptions.Add(new PropertyGroupDescription("Category"));

            cmbCountry.ItemsSource = lcv;
        }
    }
    public class CategoryItem<T>
    {
        public T Item { get; set; }
        public string Category { get; set; }
    }

Please help me...Thanks a lot in advance.

This question has already been answered. Start a new discussion instead.