public AdsCreator() { InitializeComponent(); categories = API.GetCategories(); foreach (GetCategoriesBody element in categories.response) { Label title = new Label(); title.Content = element.name; title.FontWeight = FontWeights.Heavy; Label title1 = new Label(); title1.Content = element.name; title1.FontWeight = FontWeights.Heavy; Category1.Items.Add(title); Category2.Items.Add(title1); if (element.subcategories != null) { foreach (GetCategoriesSub item in element.subcategories) { Category1.Items.Add(item.name); Category2.Items.Add(item.name); } } Category2.Items.Add(new Separator()); Category1.Items.Add(new Separator()); } }
public GetCategoriesResponse GetCategories() { HttpRequest Request = new Helper().CreateHttpRequest(_CABID, __API_VERSION, _Token); Request.AddUrlParam("lang", "ru"); string json = Request.Get(__VKAPIURL + "ads.getCategories").ToString(); GetCategoriesResponse response = JsonConvert.DeserializeObject <GetCategoriesResponse>(json); return(response); }