如何动态绑定menuitem命令 [英] How do I dynamically bind menuitem command

查看:89
本文介绍了如何动态绑定menuitem命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在我们当前的系统中(使用Visual FoxPro),我们通过从数据库中检索源数据来动态填充系统的菜单。



我们将在SQL Server数据库的表中存储菜单名称,代码,排序顺序,层次结构或任何内容,在系统初始化期间检索它们并在运行时填充菜单。 />


我们喜欢这样做,因为无论什么时候开发新模块,我们都会在数据库中添加额外的记录,它会自动在我们的系统中,而不会改变代码。



现在我们转向C#& WPF(XAML),仍然喜欢这样做。

我已经做了一些研究,并设法填充菜单&菜单项从数据库成功,除了单个菜单项的命令



假设我有这个名为Invoice Entry的菜单项,我想要它发生的是,当我点击这个菜单项时,它将打开另一个小模块(Invoice.xaml)。

像发票a =新发票(); a.ShowDialog之类的东西();



如何在数据库中存储命令并在运行时动态地将此命令分配给menuitem?

任何关键字,术语这可以帮我在网上研究吗?





抱歉我的英文不好:-)



谢谢

解决方案

我将创建一个包含db中所有选项的接口,并根据所选命令在运行时分配它

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

解决方案

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


这篇关于如何动态绑定menuitem命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆