コード例 #1
0
        /*
         * Queries the service for all type filters and then updates the view with
         * the result of the query
         */
        private void LoadTypeFilters()
        {
            //Fetch the list of catalog item types
            IEnumerable <CatalogType> types = _service.GetCatalogTypes();

            // Bind combobox to dictionary
            Dictionary <int, string> typeDictionary = new Dictionary <int, string>();

            //The service does not return an 'all' item by default, so we must add it.
            typeDictionary.Add(0, "All");

            // Add rest of type filters
            foreach (var catalogtype in types)
            {
                int    idValue   = catalogtype.Id;
                string typeValue = catalogtype.Type;
                typeDictionary.Add(idValue, typeValue);
            }

            _view.SetTypeFilter(typeDictionary);
        }