Example #1
0
        public GoodsSectionContextMenu(GoodsSection section, bool isRootItem)
        {
            MenuItem newSection = new() { Header = "New section" };

            newSection.Click += (_, _) => section.AddSubsection();

            MenuItem renameSection = new() { Header = "Rename section", IsEnabled = !isRootItem };

            renameSection.Click += (_, _) => section.Rename();

            MenuItem deleteSection = new() { Header = "Delete section", IsEnabled = !isRootItem };

            deleteSection.Click += (_, _) => section.Delete();

            MenuItem newGood = new() { Header = "New good" };

            newGood.Click += (_, _) => section.AddGood();

            Control[] contextMenuItemsCollection = { newSection, renameSection, deleteSection, new Separator(), newGood };
            ItemsSource = contextMenuItemsCollection;
        }

        public void Show() => IsOpen = true;
    }
}
Example #2
0
 public Good(GoodsSection parentSection) => ParentSection = parentSection;