コード例 #1
0
        public void UpdateCategoryCreateCategoryList()
        {
            var categories = databaseController.GetCategoriesWithItemsCount();

            TypesListBox.Items.Clear();
            foreach (var category in categories)
            {
                var categoryGrid = new Grid();
                categoryGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
                categoryGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });

                var categoryNameLabel = new Label {
                    FontSize = 16, Content = $"{category.Key}", Foreground = Brushes.White, IsHitTestVisible = false
                };
                Grid.SetColumn(categoryNameLabel, 0);
                categoryGrid.Children.Add(categoryNameLabel);

                var categoryCountLabel = new Label {
                    FontSize = 16, Content = $"({category.Value})", Foreground = Brushes.White, IsHitTestVisible = false
                };
                Grid.SetColumn(categoryCountLabel, 1);
                categoryGrid.Children.Add(categoryCountLabel);

                TypesListBox.Items.Add(categoryGrid);
            }
        }