Click here to Skip to main content
15,795,791 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

In our current system (using Visual FoxPro), we populate Menu of the system dynamically by retrieving source data from database.

We will stored the Menu Name, Code, sorting order, hierarchy or whatsoever in a table in SQL server database, retrieve them during system initialisation and populate the menu on run time.

We like to do it this way, because whenever there are new module developed, we will just add in additional record in Database, and it will automatically in our System, without changing code.

Now we are moving to C# & WPF (XAML), and still prefer to do it this way.
I have done some research, and manage to populate the Menu & Menu Item successfully from database, except the Command for individual Menu Item.

Let's say I have this menu Item called "Invoice Entry", what i want it to happen is, when I clicked on this menu item, it will open another small module(Invoice.xaml).
Something like " Invoice a = new Invoice() ; a.ShowDialog(); "

How do I stored command in Database and dynamically assign this command to menuitem during run time?
Any keyword, term that could help me research on the web?

Sorry for my bad english :-)

Thank you
Sinisa Hajnal 20-Jan-16 8:00am    
How about you create a class that will be called on any menu click and decide what should be done by module name or some other parameter? Or better yet, create interface with ExecuteMenuOption and MenuOption Factory class that will create correct menu item class that will know how to execute itself?

1 solution

I would create an interface with all the options I have in the db , and assign it during runtime based on chosen command.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900